diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 9402b7ffb..920dd71f6 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -80,7 +80,7 @@ - + diff --git a/AndroidManifest.xml.pattern b/AndroidManifest.xml.pattern index 42aa2575e..add5aecfe 100644 --- a/AndroidManifest.xml.pattern +++ b/AndroidManifest.xml.pattern @@ -80,7 +80,7 @@ - + diff --git a/assets/resources/application/en.xml b/assets/resources/application/en.xml index 832e1dd60..558c04589 100644 --- a/assets/resources/application/en.xml +++ b/assets/resources/application/en.xml @@ -15,6 +15,9 @@ + + + diff --git a/src/org/geometerplus/android/fbreader/library/LibraryBaseActivity.java b/src/org/geometerplus/android/fbreader/library/LibraryBaseActivity.java index 707516256..986714bba 100644 --- a/src/org/geometerplus/android/fbreader/library/LibraryBaseActivity.java +++ b/src/org/geometerplus/android/fbreader/library/LibraryBaseActivity.java @@ -22,6 +22,7 @@ package org.geometerplus.android.fbreader.library; import java.util.List; import android.app.ListActivity; +import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.view.*; @@ -48,6 +49,7 @@ abstract class LibraryBaseActivity extends ListActivity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); + Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this)); mySelectedBookPath = getIntent().getStringExtra(SELECTED_BOOK_PATH_KEY); } @@ -121,4 +123,22 @@ abstract class LibraryBaseActivity extends ListActivity { return view; } } + + protected class OpenTreeRunnable implements Runnable { + private final String myTreePath; + private final String mySelectedBookPath; + + public OpenTreeRunnable(String treePath, String selectedBookPath) { + myTreePath = treePath; + mySelectedBookPath = selectedBookPath; + } + + public void run() { + startActivity( + new Intent(LibraryBaseActivity.this, LibraryTreeActivity.class) + .putExtra(SELECTED_BOOK_PATH_KEY, mySelectedBookPath) + .putExtra(LibraryTreeActivity.TREE_PATH_KEY, myTreePath) + ); + } + } } diff --git a/src/org/geometerplus/android/fbreader/library/LibraryRecentActivity.java b/src/org/geometerplus/android/fbreader/library/LibraryRecentActivity.java deleted file mode 100644 index 622a0aef6..000000000 --- a/src/org/geometerplus/android/fbreader/library/LibraryRecentActivity.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2010 Geometer Plus - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -package org.geometerplus.android.fbreader.library; - -import android.os.Bundle; - -import org.geometerplus.fbreader.library.Library; - -public class LibraryRecentActivity extends LibraryTreeActivity { - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - setListAdapter(new LibraryAdapter(LibraryTopLevelActivity.Library.recentBooks().subTrees())); - } -} diff --git a/src/org/geometerplus/android/fbreader/library/LibraryTopLevelActivity.java b/src/org/geometerplus/android/fbreader/library/LibraryTopLevelActivity.java index 53d372505..3e303a79e 100644 --- a/src/org/geometerplus/android/fbreader/library/LibraryTopLevelActivity.java +++ b/src/org/geometerplus/android/fbreader/library/LibraryTopLevelActivity.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import android.content.Intent; import android.os.Bundle; import android.view.View; +import android.view.Window; import android.widget.ListView; import org.geometerplus.zlibrary.core.resources.ZLResource; @@ -42,6 +43,7 @@ public class LibraryTopLevelActivity extends LibraryBaseActivity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); + requestWindowFeature(Window.FEATURE_NO_TITLE); if (SQLiteBooksDatabase.Instance() == null) { new SQLiteBooksDatabase("LIBRARY_NG"); @@ -59,35 +61,25 @@ public class LibraryTopLevelActivity extends LibraryBaseActivity { } } )); + items.add(new TopLevelTree( + myResource.getResource("favorites"), + R.drawable.ic_tab_library_recent, + new OpenTreeRunnable(LibraryTreeActivity.PATH_FAVORITES, mySelectedBookPath) + )); items.add(new TopLevelTree( myResource.getResource("recent"), R.drawable.ic_tab_library_recent, - new Runnable() { - public void run() { - final Intent intent = new Intent( - LibraryTopLevelActivity.this, - LibraryRecentActivity.class - ); - intent.putExtra(SELECTED_BOOK_PATH_KEY, mySelectedBookPath); - startActivity(intent); - } - } + new OpenTreeRunnable(LibraryTreeActivity.PATH_RECENT, mySelectedBookPath) )); items.add(new TopLevelTree( myResource.getResource("byAuthor"), R.drawable.library_by_author, - new Runnable() { - public void run() { - } - } + new OpenTreeRunnable(LibraryTreeActivity.PATH_BY_AUTHOR, mySelectedBookPath) )); items.add(new TopLevelTree( myResource.getResource("byTag"), R.drawable.library_by_tag, - new Runnable() { - public void run() { - } - } + new OpenTreeRunnable(LibraryTreeActivity.PATH_BY_TAG, mySelectedBookPath) )); items.add(new TopLevelTree( myResource.getResource("fileTree"), diff --git a/src/org/geometerplus/android/fbreader/library/LibraryTreeActivity.java b/src/org/geometerplus/android/fbreader/library/LibraryTreeActivity.java index 919ae6c2e..e2de2bef5 100644 --- a/src/org/geometerplus/android/fbreader/library/LibraryTreeActivity.java +++ b/src/org/geometerplus/android/fbreader/library/LibraryTreeActivity.java @@ -19,17 +19,49 @@ package org.geometerplus.android.fbreader.library; - import android.content.Intent; +import android.os.Bundle; import android.view.View; import android.widget.ListView; +import org.geometerplus.fbreader.library.Library; import org.geometerplus.fbreader.library.LibraryTree; import org.geometerplus.fbreader.library.BookTree; import org.geometerplus.android.fbreader.FBReader; -abstract class LibraryTreeActivity extends LibraryBaseActivity { +public class LibraryTreeActivity extends LibraryBaseActivity { + static final String TREE_PATH_KEY = "TreePath"; + + static final String PATH_FAVORITES = "favorites"; + static final String PATH_RECENT = "recent"; + static final String PATH_BY_AUTHOR = "author"; + static final String PATH_BY_TAG = "tag"; + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + + final String[] path = getIntent().getStringExtra(TREE_PATH_KEY).split("\000"); + + final Library library = LibraryTopLevelActivity.Library; + LibraryTree root = null; + if (path.length == 1) { + if (PATH_RECENT.equals(path[0])) { + root = library.recentBooks(); + } else if (PATH_BY_AUTHOR.equals(path[0])) { + root = library.byAuthor(); + } else if (PATH_BY_TAG.equals(path[0])) { + root = library.byTag(); + } else if (PATH_FAVORITES.equals(path[0])) { + } + } + + if (root != null) { + setListAdapter(new LibraryAdapter(root.subTrees())); + } + } + @Override public void onListItemClick(ListView listView, View view, int position, long rowId) { LibraryTree tree = (LibraryTree)((LibraryAdapter)getListAdapter()).getItem(position);