Bug 760645 - Add reading list app menu item (r=mfinkle)
|
@ -570,6 +570,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
MenuItem bookmark = aMenu.findItem(R.id.bookmark);
|
||||
MenuItem forward = aMenu.findItem(R.id.forward);
|
||||
MenuItem share = aMenu.findItem(R.id.share);
|
||||
MenuItem readingList = aMenu.findItem(R.id.reading_list);
|
||||
MenuItem saveAsPDF = aMenu.findItem(R.id.save_as_pdf);
|
||||
MenuItem charEncoding = aMenu.findItem(R.id.char_encoding);
|
||||
MenuItem findInPage = aMenu.findItem(R.id.find_in_page);
|
||||
|
@ -578,6 +579,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
bookmark.setEnabled(false);
|
||||
forward.setEnabled(false);
|
||||
share.setEnabled(false);
|
||||
readingList.setEnabled(false);
|
||||
saveAsPDF.setEnabled(false);
|
||||
findInPage.setEnabled(false);
|
||||
return true;
|
||||
|
@ -594,6 +596,17 @@ abstract public class BrowserApp extends GeckoApp
|
|||
bookmark.setIcon(R.drawable.ic_menu_bookmark_add);
|
||||
}
|
||||
|
||||
readingList.setEnabled(tab.getReaderEnabled());
|
||||
readingList.setCheckable(true);
|
||||
|
||||
if (tab.isReadingListItem()) {
|
||||
readingList.setChecked(true);
|
||||
readingList.setIcon(R.drawable.ic_menu_reading_list_remove);
|
||||
} else {
|
||||
readingList.setChecked(false);
|
||||
readingList.setIcon(R.drawable.ic_menu_reading_list_add);
|
||||
}
|
||||
|
||||
forward.setEnabled(tab.canDoForward());
|
||||
|
||||
// Disable share menuitem for about:, chrome:, file:, and resource: URIs
|
||||
|
|
|
@ -653,6 +653,19 @@ abstract public class GeckoApp
|
|||
case R.id.share:
|
||||
shareCurrentUrl();
|
||||
return true;
|
||||
case R.id.reading_list:
|
||||
tab = Tabs.getInstance().getSelectedTab();
|
||||
if (tab != null) {
|
||||
if (item.isChecked()) {
|
||||
tab.removeFromReadingList();
|
||||
item.setIcon(R.drawable.ic_menu_reading_list_add);
|
||||
Toast.makeText(this, R.string.reading_list_removed, Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
tab.addToReadingList();
|
||||
item.setIcon(R.drawable.ic_menu_reading_list_remove);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case R.id.reload:
|
||||
tab = Tabs.getInstance().getSelectedTab();
|
||||
if (tab != null)
|
||||
|
|
|
@ -381,6 +381,8 @@ RES_DRAWABLE_BASE = \
|
|||
res/drawable/ic_menu_reload.png \
|
||||
res/drawable/ic_menu_save_as_pdf.png \
|
||||
res/drawable/ic_menu_share.png \
|
||||
res/drawable/ic_menu_reading_list_add.png \
|
||||
res/drawable/ic_menu_reading_list_remove.png \
|
||||
res/drawable/ic_menu_forward.png \
|
||||
res/drawable/remote_tabs_off.png \
|
||||
res/drawable/remote_tabs_on.png \
|
||||
|
@ -461,6 +463,8 @@ RES_DRAWABLE_HDPI = \
|
|||
res/drawable-hdpi/ic_menu_reload.png \
|
||||
res/drawable-hdpi/ic_menu_save_as_pdf.png \
|
||||
res/drawable-hdpi/ic_menu_share.png \
|
||||
res/drawable-hdpi/ic_menu_reading_list_add.png \
|
||||
res/drawable-hdpi/ic_menu_reading_list_remove.png \
|
||||
res/drawable-hdpi/ic_menu_forward.png \
|
||||
res/drawable-hdpi/remote_tabs_off.png \
|
||||
res/drawable-hdpi/remote_tabs_on.png \
|
||||
|
@ -509,6 +513,8 @@ RES_DRAWABLE_MDPI_V11 = \
|
|||
res/drawable-mdpi-v11/ic_menu_reload.png \
|
||||
res/drawable-mdpi-v11/ic_menu_save_as_pdf.png \
|
||||
res/drawable-mdpi-v11/ic_menu_share.png \
|
||||
res/drawable-mdpi-v11/ic_menu_reading_list_add.png \
|
||||
res/drawable-mdpi-v11/ic_menu_reading_list_remove.png \
|
||||
res/drawable-mdpi-v11/ic_menu_forward.png \
|
||||
res/drawable-mdpi-v11/menu.png \
|
||||
res/drawable-mdpi-v11/menu_panel_bg.9.png \
|
||||
|
@ -531,6 +537,8 @@ RES_DRAWABLE_HDPI_V11 = \
|
|||
res/drawable-hdpi-v11/ic_menu_reload.png \
|
||||
res/drawable-hdpi-v11/ic_menu_save_as_pdf.png \
|
||||
res/drawable-hdpi-v11/ic_menu_share.png \
|
||||
res/drawable-hdpi-v11/ic_menu_reading_list_add.png \
|
||||
res/drawable-hdpi-v11/ic_menu_reading_list_remove.png \
|
||||
res/drawable-hdpi-v11/ic_menu_forward.png \
|
||||
res/drawable-hdpi-v11/menu.png \
|
||||
res/drawable-hdpi-v11/menu_panel_bg.9.png \
|
||||
|
@ -570,6 +578,8 @@ RES_DRAWABLE_XHDPI_V11 = \
|
|||
res/drawable-xhdpi-v11/ic_menu_reload.png \
|
||||
res/drawable-xhdpi-v11/ic_menu_save_as_pdf.png \
|
||||
res/drawable-xhdpi-v11/ic_menu_share.png \
|
||||
res/drawable-xhdpi-v11/ic_menu_reading_list_add.png \
|
||||
res/drawable-xhdpi-v11/ic_menu_reading_list_remove.png \
|
||||
res/drawable-xhdpi-v11/remote_tabs_off.png \
|
||||
res/drawable-xhdpi-v11/remote_tabs_on.png \
|
||||
res/drawable-xhdpi-v11/tab_new.png \
|
||||
|
|
|
@ -51,6 +51,7 @@ public final class Tab {
|
|||
private int mParentId;
|
||||
private boolean mExternal;
|
||||
private boolean mBookmark;
|
||||
private boolean mReadingListItem;
|
||||
private HashMap<String, DoorHanger> mDoorHangers;
|
||||
private long mFaviconLoadId;
|
||||
private String mDocumentURI;
|
||||
|
@ -89,6 +90,7 @@ public final class Tab {
|
|||
mHistoryIndex = -1;
|
||||
mHistorySize = 0;
|
||||
mBookmark = false;
|
||||
mReadingListItem = false;
|
||||
mDoorHangers = new HashMap<String, DoorHanger>();
|
||||
mFaviconLoadId = 0;
|
||||
mDocumentURI = "";
|
||||
|
@ -100,6 +102,7 @@ public final class Tab {
|
|||
mContentObserver = new ContentObserver(GeckoAppShell.getHandler()) {
|
||||
public void onChange(boolean selfChange) {
|
||||
updateBookmark();
|
||||
updateReadingListItem();
|
||||
}
|
||||
};
|
||||
BrowserDB.registerBookmarkObserver(mContentResolver, mContentObserver);
|
||||
|
@ -234,6 +237,10 @@ public final class Tab {
|
|||
return mBookmark;
|
||||
}
|
||||
|
||||
public boolean isReadingListItem() {
|
||||
return mReadingListItem;
|
||||
}
|
||||
|
||||
public boolean isExternal() {
|
||||
return mExternal;
|
||||
}
|
||||
|
@ -243,6 +250,7 @@ public final class Tab {
|
|||
mUrl = url;
|
||||
Log.i(LOGTAG, "Updated url: " + url + " for tab with id: " + mId);
|
||||
updateBookmark();
|
||||
updateReadingListItem();
|
||||
updateHistory(mUrl, mTitle);
|
||||
}
|
||||
}
|
||||
|
@ -390,6 +398,21 @@ public final class Tab {
|
|||
});
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addBookmark() {
|
||||
GeckoAppShell.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -422,6 +445,28 @@ public final class Tab {
|
|||
GeckoAppShell.sendEventToGecko(e);
|
||||
}
|
||||
|
||||
public void removeFromReadingList() {
|
||||
if (!mReaderEnabled)
|
||||
return;
|
||||
|
||||
GeckoAppShell.getHandler().post(new Runnable() {
|
||||
public void run() {
|
||||
String url = getURL();
|
||||
if (url == null)
|
||||
return;
|
||||
|
||||
BrowserDB.removeReadingListItemWithURL(mContentResolver, url);
|
||||
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
GeckoEvent e = GeckoEvent.createBroadcastEvent("Reader:Remove", getURL());
|
||||
GeckoAppShell.sendEventToGecko(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void readerMode() {
|
||||
if (!mReaderEnabled)
|
||||
return;
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
<!ENTITY site_settings_clear "Clear">
|
||||
<!ENTITY site_settings_no_settings "There are no settings to clear.">
|
||||
|
||||
<!ENTITY add_to_reading_list "Add to Reading List">
|
||||
<!ENTITY reading_list "Reading List">
|
||||
<!ENTITY reading_list_added "Page added to your Reading List">
|
||||
<!ENTITY reading_list_removed "Page removed from your Reading List">
|
||||
<!ENTITY reading_list_failed "Failed to add page to your Reading List">
|
||||
|
|
Двоичные данные
mobile/android/base/resources/drawable-hdpi-v11/ic_menu_reading_list_add.png
Normal file
После Ширина: | Высота: | Размер: 1.6 KiB |
Двоичные данные
mobile/android/base/resources/drawable-hdpi-v11/ic_menu_reading_list_remove.png
Normal file
После Ширина: | Высота: | Размер: 1.7 KiB |
Двоичные данные
mobile/android/base/resources/drawable-hdpi/ic_menu_reading_list_add.png
Normal file
После Ширина: | Высота: | Размер: 1.8 KiB |
Двоичные данные
mobile/android/base/resources/drawable-hdpi/ic_menu_reading_list_remove.png
Normal file
После Ширина: | Высота: | Размер: 2.3 KiB |
Двоичные данные
mobile/android/base/resources/drawable-mdpi-v11/ic_menu_reading_list_add.png
Normal file
После Ширина: | Высота: | Размер: 1.3 KiB |
Двоичные данные
mobile/android/base/resources/drawable-mdpi-v11/ic_menu_reading_list_remove.png
Normal file
После Ширина: | Высота: | Размер: 1.4 KiB |
Двоичные данные
mobile/android/base/resources/drawable-xhdpi-v11/ic_menu_reading_list_add.png
Normal file
После Ширина: | Высота: | Размер: 1.8 KiB |
Двоичные данные
mobile/android/base/resources/drawable-xhdpi-v11/ic_menu_reading_list_remove.png
Normal file
После Ширина: | Высота: | Размер: 1.8 KiB |
После Ширина: | Высота: | Размер: 1.1 KiB |
После Ширина: | Высота: | Размер: 1.3 KiB |
|
@ -25,6 +25,10 @@
|
|||
gecko:icon="@drawable/ic_menu_share"
|
||||
gecko:title="@string/share" />
|
||||
|
||||
<item gecko:id="@+id/reading_list"
|
||||
gecko:icon="@drawable/ic_menu_reading_list_add"
|
||||
gecko:title="@string/reading_list" />
|
||||
|
||||
<item gecko:id="@+id/save_as_pdf"
|
||||
gecko:icon="@drawable/ic_menu_save_as_pdf"
|
||||
gecko:title="@string/save_as_pdf" />
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
gecko:icon="@drawable/ic_menu_share"
|
||||
gecko:title="@string/share" />
|
||||
|
||||
<item gecko:id="@+id/reading_list"
|
||||
gecko:icon="@drawable/ic_menu_reading_list_add"
|
||||
gecko:title="@string/reading_list" />
|
||||
|
||||
<item gecko:id="@+id/save_as_pdf"
|
||||
gecko:icon="@drawable/ic_menu_save_as_pdf"
|
||||
gecko:title="@string/save_as_pdf" />
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
gecko:icon="@drawable/ic_menu_share"
|
||||
gecko:title="@string/share" />
|
||||
|
||||
<item gecko:id="@+id/reading_list"
|
||||
gecko:icon="@drawable/ic_menu_reading_list_add"
|
||||
gecko:title="@string/reading_list" />
|
||||
|
||||
<item gecko:id="@+id/save_as_pdf"
|
||||
gecko:icon="@drawable/ic_menu_save_as_pdf"
|
||||
gecko:title="@string/save_as_pdf" />
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
android:icon="@drawable/ic_menu_share"
|
||||
android:title="@string/share" />
|
||||
|
||||
<item android:id="@+id/reading_list"
|
||||
android:icon="@drawable/ic_menu_reading_list_add"
|
||||
android:title="@string/reading_list" />
|
||||
|
||||
<item android:id="@+id/save_as_pdf"
|
||||
android:icon="@drawable/ic_menu_save_as_pdf"
|
||||
android:title="@string/save_as_pdf" />
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
<string name="site_settings_clear">&site_settings_clear;</string>
|
||||
<string name="site_settings_no_settings">&site_settings_no_settings;</string>
|
||||
|
||||
<string name="add_to_reading_list">&add_to_reading_list;</string>
|
||||
<string name="reading_list">&reading_list;</string>
|
||||
<string name="reading_list_added">&reading_list_added;</string>
|
||||
<string name="reading_list_removed">&reading_list_removed;</string>
|
||||
<string name="reading_list_failed">&reading_list_failed;</string>
|
||||
|
|