1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +02:00

cleanup: TextSearchActivity has gone

This commit is contained in:
Nikolay Pultsin 2011-01-23 16:10:52 +00:00
parent f8c0b02184
commit 2f318fe914
5 changed files with 39 additions and 87 deletions

View file

@ -50,15 +50,12 @@
<data android:mimeType="application/x-fictionbook+xml" /> <data android:mimeType="application/x-fictionbook+xml" />
<data android:mimeType="application/x-fictionbook" /> <data android:mimeType="application/x-fictionbook" />
</intent-filter> </intent-filter>
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.TextSearchActivity" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.BookInfoActivity" android:configChanges="orientation|keyboardHidden" android:process=":library"/>
<activity android:name="org.geometerplus.android.fbreader.TextSearchActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEARCH" /> <action android:name="android.intent.action.SEARCH" />
</intent-filter> </intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity> </activity>
<activity android:name="org.geometerplus.android.fbreader.BookInfoActivity" android:configChanges="orientation|keyboardHidden" android:process=":library"/>
<service android:name="org.geometerplus.android.fbreader.library.InitializationService" android:process=":library" /> <service android:name="org.geometerplus.android.fbreader.library.InitializationService" android:process=":library" />
<receiver android:name="org.geometerplus.android.fbreader.library.KillerCallback" 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"> <activity android:name="org.geometerplus.android.fbreader.library.LibraryTopLevelActivity" android:launchMode="singleTask" android:process=":library" android:configChanges="orientation|keyboardHidden">

View file

@ -50,15 +50,12 @@
<data android:mimeType="application/x-fictionbook+xml" /> <data android:mimeType="application/x-fictionbook+xml" />
<data android:mimeType="application/x-fictionbook" /> <data android:mimeType="application/x-fictionbook" />
</intent-filter> </intent-filter>
<meta-data android:name="android.app.default_searchable" android:value="org.geometerplus.android.fbreader.TextSearchActivity" />
</activity>
<activity android:name="org.geometerplus.android.fbreader.BookInfoActivity" android:configChanges="orientation|keyboardHidden" android:process=":library"/>
<activity android:name="org.geometerplus.android.fbreader.TextSearchActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEARCH" /> <action android:name="android.intent.action.SEARCH" />
</intent-filter> </intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</activity> </activity>
<activity android:name="org.geometerplus.android.fbreader.BookInfoActivity" android:configChanges="orientation|keyboardHidden" android:process=":library"/>
<service android:name="org.geometerplus.android.fbreader.library.InitializationService" android:process=":library" /> <service android:name="org.geometerplus.android.fbreader.library.InitializationService" android:process=":library" />
<receiver android:name="org.geometerplus.android.fbreader.library.KillerCallback" 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"> <activity android:name="org.geometerplus.android.fbreader.library.LibraryTopLevelActivity" android:launchMode="singleTask" android:process=":library" android:configChanges="orientation|keyboardHidden">

View file

@ -25,8 +25,9 @@ import android.app.SearchManager;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.os.Handler;
import android.view.WindowManager; import android.os.Message;
import android.view.*;
import android.widget.*; import android.widget.*;
import org.geometerplus.zlibrary.core.application.ZLApplication; 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.fbreader.library.KillerCallback;
import org.geometerplus.android.util.UIUtil;
public final class FBReader extends ZLAndroidActivity { public final class FBReader extends ZLAndroidActivity {
public static final String BOOK_PATH_KEY = "BookPath"; 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)); 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 @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();

View file

@ -1,75 +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 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;
}
}

View file

@ -204,9 +204,8 @@ public abstract class ZLAndroidActivity extends Activity {
} }
@Override @Override
public void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
ZLApplication.Instance().openFile(fileFromIntent(intent)); ZLApplication.Instance().openFile(fileFromIntent(intent));
} }