mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
popup windows refactoring
This commit is contained in:
parent
14c0b2c101
commit
8b73346089
7 changed files with 230 additions and 265 deletions
|
@ -53,9 +53,6 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
|
||||
private int myFullScreenFlag;
|
||||
|
||||
private static TextSearchButtonPanel ourTextSearchPanel;
|
||||
private static NavigationButtonPanel ourNavigatePanel;
|
||||
|
||||
@Override
|
||||
protected ZLFile fileFromIntent(Intent intent) {
|
||||
String filePath = intent.getStringExtra(BOOK_PATH_KEY);
|
||||
|
@ -79,11 +76,11 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
);
|
||||
|
||||
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
||||
if (ourTextSearchPanel == null) {
|
||||
ourTextSearchPanel = new TextSearchButtonPanel(fbReader);
|
||||
if (fbReader.getPopupById(TextSearchPopup.ID) == null) {
|
||||
new TextSearchPopup(fbReader);
|
||||
}
|
||||
if (ourNavigatePanel == null) {
|
||||
ourNavigatePanel = new NavigationButtonPanel(fbReader);
|
||||
if (fbReader.getPopupById(NavigationPopup.ID) == null) {
|
||||
new NavigationPopup(fbReader);
|
||||
}
|
||||
|
||||
fbReader.addAction(ActionCode.SHOW_LIBRARY, new ShowLibraryAction(this, fbReader));
|
||||
|
@ -135,20 +132,21 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
final String pattern = intent.getStringExtra(SearchManager.QUERY);
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
ourTextSearchPanel.initPosition();
|
||||
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
||||
final TextSearchPopup popup = (TextSearchPopup)fbReader.getPopupById(TextSearchPopup.ID);
|
||||
popup.initPosition();
|
||||
fbReader.TextSearchPatternOption.setValue(pattern);
|
||||
if (fbReader.getTextView().search(pattern, true, false, false, false) != 0) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
ourTextSearchPanel.show(true);
|
||||
fbReader.showPopup(popup.getId());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
UIUtil.showErrorMessage(FBReader.this, "textNotFound");
|
||||
ourTextSearchPanel.StartPosition = null;
|
||||
popup.StartPosition = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -173,13 +171,10 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
startActivity(new Intent(this, this.getClass()));
|
||||
}
|
||||
|
||||
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
||||
final RelativeLayout root = (RelativeLayout)findViewById(R.id.root_view);
|
||||
if (!ourTextSearchPanel.hasControlPanel()) {
|
||||
ourTextSearchPanel.createControlPanel(this, root, ControlPanel.Location.Bottom);
|
||||
}
|
||||
if (!ourNavigatePanel.hasControlPanel()) {
|
||||
ourNavigatePanel.createControlPanel(this, root, ControlPanel.Location.Bottom);
|
||||
}
|
||||
((PopupPanel)fbReader.getPopupById(TextSearchPopup.ID)).createControlPanel(this, root, PopupWindow.Location.Bottom);
|
||||
((PopupPanel)fbReader.getPopupById(NavigationPopup.ID)).createControlPanel(this, root, PopupWindow.Location.Bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -189,18 +184,12 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
sendBroadcast(new Intent(getApplicationContext(), KillerCallback.class));
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
ControlButtonPanel.restoreVisibilities(FBReaderApp.Instance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
ControlButtonPanel.saveVisibilities(FBReaderApp.Instance());
|
||||
super.onPause();
|
||||
PopupPanel.restoreVisibilities(FBReaderApp.Instance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
ControlButtonPanel.removeControlPanels(FBReaderApp.Instance());
|
||||
PopupPanel.removeAllWindows(FBReaderApp.Instance());
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
@ -215,12 +204,14 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
@Override
|
||||
public boolean onSearchRequested() {
|
||||
final FBReaderApp fbreader = (FBReaderApp)FBReaderApp.Instance();
|
||||
ControlButtonPanel.saveVisibilities(fbreader);
|
||||
ControlButtonPanel.hideAllPendingNotify(fbreader);
|
||||
final FBReaderApp.PopupPanel popup = fbreader.getActivePopup();
|
||||
fbreader.hideActivePopup();
|
||||
final SearchManager manager = (SearchManager)getSystemService(SEARCH_SERVICE);
|
||||
manager.setOnCancelListener(new SearchManager.OnCancelListener() {
|
||||
public void onCancel() {
|
||||
ControlButtonPanel.restoreVisibilities(fbreader);
|
||||
if (popup != null) {
|
||||
fbreader.showPopup(popup.getId());
|
||||
}
|
||||
manager.setOnCancelListener(null);
|
||||
}
|
||||
});
|
||||
|
@ -263,7 +254,7 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
}
|
||||
|
||||
public void navigate() {
|
||||
ourNavigatePanel.runNavigation();
|
||||
((NavigationPopup)FBReaderApp.Instance().getPopupById(NavigationPopup.ID)).runNavigation();
|
||||
}
|
||||
|
||||
private void addMenuItem(Menu menu, String actionId, int iconId) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue