From 2f318fe9148fbb8494cc280ee7c29b8772701e49 Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Sun, 23 Jan 2011 16:10:52 +0000 Subject: [PATCH] cleanup: TextSearchActivity has gone --- AndroidManifest.xml | 5 +- AndroidManifest.xml.pattern | 5 +- .../android/fbreader/FBReader.java | 38 +++++++++- .../android/fbreader/TextSearchActivity.java | 75 ------------------- .../ui/android/library/ZLAndroidActivity.java | 3 +- 5 files changed, 39 insertions(+), 87 deletions(-) delete mode 100644 src/org/geometerplus/android/fbreader/TextSearchActivity.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c139719ec..6c7079915 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -50,15 +50,12 @@ - - - - + diff --git a/AndroidManifest.xml.pattern b/AndroidManifest.xml.pattern index f218c5d59..560269374 100644 --- a/AndroidManifest.xml.pattern +++ b/AndroidManifest.xml.pattern @@ -50,15 +50,12 @@ - - - - + diff --git a/src/org/geometerplus/android/fbreader/FBReader.java b/src/org/geometerplus/android/fbreader/FBReader.java index b3794f196..42a4b59d6 100644 --- a/src/org/geometerplus/android/fbreader/FBReader.java +++ b/src/org/geometerplus/android/fbreader/FBReader.java @@ -25,8 +25,9 @@ import android.app.SearchManager; import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.view.View; -import android.view.WindowManager; +import android.os.Handler; +import android.os.Message; +import android.view.*; import android.widget.*; import org.geometerplus.zlibrary.core.application.ZLApplication; @@ -51,6 +52,8 @@ import org.geometerplus.fbreader.library.Book; import org.geometerplus.android.fbreader.library.KillerCallback; +import org.geometerplus.android.util.UIUtil; + public final class FBReader extends ZLAndroidActivity { public static final String BOOK_PATH_KEY = "BookPath"; @@ -145,6 +148,37 @@ public final class FBReader extends ZLAndroidActivity { fbReader.addAction(ActionCode.PROCESS_HYPERLINK, new ProcessHyperlinkAction(this, fbReader)); } + @Override + protected void onNewIntent(Intent intent) { + if (Intent.ACTION_SEARCH.equals(intent.getAction())) { + final String pattern = intent.getStringExtra(SearchManager.QUERY); + final Handler successHandler = new Handler() { + public void handleMessage(Message message) { + showTextSearchControls(true); + } + }; + final Handler failureHandler = new Handler() { + public void handleMessage(Message message) { + UIUtil.showErrorMessage(FBReader.this, "textNotFound"); + } + }; + final Runnable runnable = new Runnable() { + public void run() { + final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance(); + fbReader.TextSearchPatternOption.setValue(pattern); + if (fbReader.getTextView().search(pattern, true, false, false, false) != 0) { + successHandler.sendEmptyMessage(0); + } else { + failureHandler.sendEmptyMessage(0); + } + } + }; + UIUtil.wait("search", runnable, this); + } else { + super.onNewIntent(intent); + } + } + @Override public void onStart() { super.onStart(); diff --git a/src/org/geometerplus/android/fbreader/TextSearchActivity.java b/src/org/geometerplus/android/fbreader/TextSearchActivity.java deleted file mode 100644 index 55a1c674f..000000000 --- a/src/org/geometerplus/android/fbreader/TextSearchActivity.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2009-2011 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; - -import android.app.Activity; -import android.app.SearchManager; -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; - -import org.geometerplus.fbreader.fbreader.FBReaderApp; - -import org.geometerplus.android.util.UIUtil; - -public class TextSearchActivity extends Activity { - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - Thread.setDefaultUncaughtExceptionHandler(new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this)); - - final SearchManager manager = (SearchManager)getSystemService(SEARCH_SERVICE); - manager.setOnCancelListener(null); - - final Intent intent = getIntent(); - if (Intent.ACTION_SEARCH.equals(intent.getAction())) { - final String pattern = intent.getStringExtra(SearchManager.QUERY); - final Handler successHandler = new Handler() { - public void handleMessage(Message message) { - FBReader.Instance.showTextSearchControls(true); - } - }; - final Handler failureHandler = new Handler() { - public void handleMessage(Message message) { - UIUtil.showErrorMessage(getParentActivity(), "textNotFound"); - } - }; - final Runnable runnable = new Runnable() { - public void run() { - final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance(); - fbReader.TextSearchPatternOption.setValue(pattern); - if (fbReader.getTextView().search(pattern, true, false, false, false) != 0) { - successHandler.sendEmptyMessage(0); - } else { - failureHandler.sendEmptyMessage(0); - } - } - }; - UIUtil.wait("search", runnable, getParentActivity()); - } - finish(); - } - - private Activity getParentActivity() { - return FBReader.Instance; - } -} diff --git a/src/org/geometerplus/zlibrary/ui/android/library/ZLAndroidActivity.java b/src/org/geometerplus/zlibrary/ui/android/library/ZLAndroidActivity.java index 490985f66..845267cca 100644 --- a/src/org/geometerplus/zlibrary/ui/android/library/ZLAndroidActivity.java +++ b/src/org/geometerplus/zlibrary/ui/android/library/ZLAndroidActivity.java @@ -204,9 +204,8 @@ public abstract class ZLAndroidActivity extends Activity { } @Override - public void onNewIntent(Intent intent) { + protected void onNewIntent(Intent intent) { super.onNewIntent(intent); - ZLApplication.Instance().openFile(fileFromIntent(intent)); }