зеркало из https://github.com/mozilla/gecko-dev.git
Bug 842883 - (Part 2) Move the Reader:* event handlers out of Tabs that don't need to be there. r=bnicholson
This commit is contained in:
Родитель
be16192d59
Коммит
dbb131c728
|
@ -179,6 +179,29 @@ abstract public class BrowserApp extends GeckoApp
|
|||
});
|
||||
}
|
||||
|
||||
void handleReaderAdded(boolean success, final String title, final String url) {
|
||||
if (!success) {
|
||||
showToast(R.string.reading_list_failed, Toast.LENGTH_SHORT);
|
||||
return;
|
||||
}
|
||||
|
||||
GeckoAppShell.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
BrowserDB.addReadingListItem(getContentResolver(), title, url);
|
||||
showToast(R.string.reading_list_added, Toast.LENGTH_SHORT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void handleReaderRemoved(final String url) {
|
||||
GeckoAppShell.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
BrowserDB.removeReadingListItemWithURL(getContentResolver(), url);
|
||||
showToast(R.string.reading_list_removed, Toast.LENGTH_SHORT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void handleReaderEnabled(final int tabId) {
|
||||
super.handleReaderEnabled(tabId);
|
||||
final Tab tab = Tabs.getInstance().getTab(tabId);
|
||||
|
@ -530,6 +553,19 @@ abstract public class BrowserApp extends GeckoApp
|
|||
Telemetry.HistogramAdd("PLACES_BOOKMARKS_COUNT", BrowserDB.getCount(getContentResolver(), "bookmarks"));
|
||||
Telemetry.HistogramAdd("FENNEC_FAVICONS_COUNT", BrowserDB.getCount(getContentResolver(), "favicons"));
|
||||
Telemetry.HistogramAdd("FENNEC_THUMBNAILS_COUNT", BrowserDB.getCount(getContentResolver(), "thumbnails"));
|
||||
} else if (event.equals("Reader:Added")) {
|
||||
final boolean success = message.getBoolean("success");
|
||||
final String title = message.getString("title");
|
||||
final String url = message.getString("url");
|
||||
handleReaderAdded(success, title, url);
|
||||
} else if (event.equals("Reader:Removed")) {
|
||||
final String url = message.getString("url");
|
||||
handleReaderRemoved(url);
|
||||
} else if (event.equals("Reader:Share")) {
|
||||
final String title = message.getString("title");
|
||||
final String url = message.getString("url");
|
||||
GeckoAppShell.openUriExternal(url, "text/plain", "", "",
|
||||
Intent.ACTION_SEND, title);
|
||||
} else {
|
||||
super.handleMessage(event, message);
|
||||
}
|
||||
|
|
|
@ -1734,6 +1734,9 @@ abstract public class GeckoApp
|
|||
registerEventListener("Content:StateChange");
|
||||
registerEventListener("Content:LoadError");
|
||||
registerEventListener("Content:PageShow");
|
||||
registerEventListener("Reader:Added");
|
||||
registerEventListener("Reader:Removed");
|
||||
registerEventListener("Reader:Share");
|
||||
registerEventListener("Reader:FaviconRequest");
|
||||
registerEventListener("Reader:GoToReadingList");
|
||||
registerEventListener("onCameraCapture");
|
||||
|
@ -2132,6 +2135,9 @@ abstract public class GeckoApp
|
|||
unregisterEventListener("Content:StateChange");
|
||||
unregisterEventListener("Content:LoadError");
|
||||
unregisterEventListener("Content:PageShow");
|
||||
unregisterEventListener("Reader:Added");
|
||||
unregisterEventListener("Reader:Removed");
|
||||
unregisterEventListener("Reader:Share");
|
||||
unregisterEventListener("Reader:FaviconRequest");
|
||||
unregisterEventListener("Reader:GoToReadingList");
|
||||
unregisterEventListener("onCameraCapture");
|
||||
|
|
|
@ -69,9 +69,6 @@ public class Tabs implements GeckoEventListener {
|
|||
registerEventListener("Tab:Select");
|
||||
registerEventListener("Content:LocationChange");
|
||||
registerEventListener("Session:RestoreEnd");
|
||||
registerEventListener("Reader:Added");
|
||||
registerEventListener("Reader:Removed");
|
||||
registerEventListener("Reader:Share");
|
||||
registerEventListener("DOMTitleChanged");
|
||||
registerEventListener("DOMLinkAdded");
|
||||
registerEventListener("DOMWindowClose");
|
||||
|
@ -322,20 +319,6 @@ public class Tabs implements GeckoEventListener {
|
|||
}
|
||||
} else if (event.equals("Session:RestoreEnd")) {
|
||||
notifyListeners(null, TabEvents.RESTORED);
|
||||
} else if (event.equals("Reader:Added")) {
|
||||
final boolean success = message.getBoolean("success");
|
||||
final String title = message.getString("title");
|
||||
final String url = message.getString("url");
|
||||
handleReaderAdded(success, title, url);
|
||||
} else if (event.equals("Reader:Removed")) {
|
||||
final String url = message.getString("url");
|
||||
handleReaderRemoved(url);
|
||||
} else if (event.equals("Reader:Share")) {
|
||||
final String title = message.getString("title");
|
||||
final String url = message.getString("url");
|
||||
|
||||
GeckoAppShell.openUriExternal(url, "text/plain", "", "",
|
||||
Intent.ACTION_SEND, title);
|
||||
} else if (event.equals("DOMTitleChanged")) {
|
||||
Tab tab = getTab(message.getInt("tabID"));
|
||||
if (tab != null) {
|
||||
|
@ -356,29 +339,6 @@ public class Tabs implements GeckoEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
void handleReaderAdded(boolean success, final String title, final String url) {
|
||||
if (!success) {
|
||||
mActivity.showToast(R.string.reading_list_failed, Toast.LENGTH_SHORT);
|
||||
return;
|
||||
}
|
||||
|
||||
GeckoAppShell.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
BrowserDB.addReadingListItem(getContentResolver(), title, url);
|
||||
mActivity.showToast(R.string.reading_list_added, Toast.LENGTH_SHORT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void handleReaderRemoved(final String url) {
|
||||
GeckoAppShell.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
BrowserDB.removeReadingListItemWithURL(getContentResolver(), url);
|
||||
mActivity.showToast(R.string.reading_list_removed, Toast.LENGTH_SHORT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refreshThumbnails() {
|
||||
final ThumbnailHelper helper = ThumbnailHelper.getInstance();
|
||||
Iterator<Tab> iterator = mTabs.values().iterator();
|
||||
|
|
Загрузка…
Ссылка в новой задаче