mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
BookmarksActivity search code cleanup: separate search activity has been removed
This commit is contained in:
parent
7462fab0dc
commit
b48b7c0c54
4 changed files with 54 additions and 87 deletions
|
@ -59,12 +59,6 @@
|
|||
</intent-filter>
|
||||
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
|
||||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.BookmarkSearchActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
|
||||
</activity>
|
||||
<service android:name="org.geometerplus.android.fbreader.library.InitializationService" android:process=":library" />
|
||||
<receiver android:name="org.geometerplus.android.fbreader.library.KillerCallback" android:process=":library" />
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.LibraryTopLevelActivity" android:launchMode="singleTask" android:process=":library" android:configChanges="orientation|keyboardHidden">
|
||||
|
@ -84,8 +78,11 @@
|
|||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.FileManager" android:process=":library"/>
|
||||
<activity android:name="org.geometerplus.android.fbreader.TOCActivity" android:configChanges="orientation|keyboardHidden" />
|
||||
<activity android:name="org.geometerplus.android.fbreader.BookmarksActivity" android:configChanges="orientation|keyboardHidden">
|
||||
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.BookmarkSearchActivity" />
|
||||
<activity android:name="org.geometerplus.android.fbreader.BookmarksActivity" android:launchMode="singleTask" android:configChanges="orientation|keyboardHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
|
||||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.BookmarkEditActivity" android:theme="@android:style/Theme.Dialog" android:configChanges="orientation|keyboardHidden" />
|
||||
<activity android:name="org.geometerplus.android.fbreader.preferences.PreferenceActivity" android:configChanges="orientation|keyboardHidden" />
|
||||
|
|
|
@ -59,12 +59,6 @@
|
|||
</intent-filter>
|
||||
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
|
||||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.BookmarkSearchActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
|
||||
</activity>
|
||||
<service android:name="org.geometerplus.android.fbreader.library.InitializationService" android:process=":library" />
|
||||
<receiver android:name="org.geometerplus.android.fbreader.library.KillerCallback" android:process=":library" />
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.LibraryTopLevelActivity" android:launchMode="singleTask" android:process=":library" android:configChanges="orientation|keyboardHidden">
|
||||
|
@ -84,8 +78,11 @@
|
|||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.FileManager" android:process=":library"/>
|
||||
<activity android:name="org.geometerplus.android.fbreader.TOCActivity" android:configChanges="orientation|keyboardHidden" />
|
||||
<activity android:name="org.geometerplus.android.fbreader.BookmarksActivity" android:configChanges="orientation|keyboardHidden">
|
||||
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.BookmarkSearchActivity" />
|
||||
<activity android:name="org.geometerplus.android.fbreader.BookmarksActivity" android:launchMode="singleTask" android:configChanges="orientation|keyboardHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
|
||||
</activity>
|
||||
<activity android:name="org.geometerplus.android.fbreader.BookmarkEditActivity" android:theme="@android:style/Theme.Dialog" android:configChanges="orientation|keyboardHidden" />
|
||||
<activity android:name="org.geometerplus.android.fbreader.preferences.PreferenceActivity" android:configChanges="orientation|keyboardHidden" />
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2011 Geometer Plus <contact@geometerplus.com>
|
||||
*
|
||||
* 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;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||
import org.geometerplus.fbreader.library.*;
|
||||
|
||||
public class BookmarkSearchActivity extends SearchActivity {
|
||||
private final LinkedList<Bookmark> myBookmarks = new LinkedList<Bookmark>();
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
BookmarksActivity.Instance.showSearchResultsTab(myBookmarks);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void onFailure() {
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public String getFailureMessageResourceKey() {
|
||||
return "bookmarkNotFound";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWaitMessageResourceKey() {
|
||||
return "search";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runSearch(String pattern) {
|
||||
final FBReaderApp fbreader = (FBReaderApp)FBReaderApp.Instance();
|
||||
fbreader.BookmarkSearchPatternOption.setValue(pattern);
|
||||
pattern = pattern.toLowerCase();
|
||||
myBookmarks.clear();
|
||||
for (Bookmark bookmark : BookmarksActivity.Instance.AllBooksBookmarks) {
|
||||
if (ZLMiscUtil.matchesIgnoreCase(bookmark.getText(), pattern)) {
|
||||
myBookmarks.add(bookmark);
|
||||
}
|
||||
}
|
||||
return !myBookmarks.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity getParentActivity() {
|
||||
return BookmarksActivity.Instance;
|
||||
}
|
||||
}
|
|
@ -21,12 +21,13 @@ package org.geometerplus.android.fbreader;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
import android.app.*;
|
||||
import android.os.*;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import android.content.*;
|
||||
import android.app.TabActivity;
|
||||
|
||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
import org.geometerplus.zlibrary.text.view.*;
|
||||
|
||||
|
@ -35,6 +36,8 @@ import org.geometerplus.zlibrary.ui.android.R;
|
|||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||
import org.geometerplus.fbreader.library.*;
|
||||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
|
||||
public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuItemClickListener {
|
||||
static BookmarksActivity Instance;
|
||||
|
||||
|
@ -68,6 +71,9 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
|
|||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
|
||||
|
||||
final SearchManager manager = (SearchManager)getSystemService(SEARCH_SERVICE);
|
||||
manager.setOnCancelListener(null);
|
||||
|
||||
final TabHost host = getTabHost();
|
||||
LayoutInflater.from(this).inflate(R.layout.bookmarks, host.getTabContentView(), true);
|
||||
|
||||
|
@ -95,6 +101,43 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
|
|||
findViewById(R.id.search_results).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public List<Bookmark> runSearch(String pattern) {
|
||||
final FBReaderApp fbreader = (FBReaderApp)FBReaderApp.Instance();
|
||||
fbreader.BookmarkSearchPatternOption.setValue(pattern);
|
||||
|
||||
final LinkedList<Bookmark> bookmarks = new LinkedList<Bookmark>();
|
||||
pattern = pattern.toLowerCase();
|
||||
for (Bookmark bookmark : BookmarksActivity.Instance.AllBooksBookmarks) {
|
||||
if (ZLMiscUtil.matchesIgnoreCase(bookmark.getText(), pattern)) {
|
||||
bookmarks.add(bookmark);
|
||||
}
|
||||
}
|
||||
return bookmarks;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
if (!Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||
return;
|
||||
}
|
||||
String pattern = intent.getStringExtra(SearchManager.QUERY);
|
||||
final FBReaderApp fbreader = (FBReaderApp)FBReaderApp.Instance();
|
||||
fbreader.BookmarkSearchPatternOption.setValue(pattern);
|
||||
|
||||
final LinkedList<Bookmark> bookmarks = new LinkedList<Bookmark>();
|
||||
pattern = pattern.toLowerCase();
|
||||
for (Bookmark b : BookmarksActivity.Instance.AllBooksBookmarks) {
|
||||
if (ZLMiscUtil.matchesIgnoreCase(b.getText(), pattern)) {
|
||||
bookmarks.add(b);
|
||||
}
|
||||
}
|
||||
if (!bookmarks.isEmpty()) {
|
||||
showSearchResultsTab(bookmarks);
|
||||
} else {
|
||||
UIUtil.showErrorMessage(this, "bookmarkNotFound");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue