@ActionMethod( ids = { R.id.mainmenu_zoom, R.id.actions_toggleTouchManagerView, R.id.mainmenu_search, R.id.mainmenu_crop }) public void toggleControls(final ActionEx action) { final View view = action.getParameter("view"); final DocumentViewMode mode = action.getParameter("mode"); if (mode != null && bookSettings != null && bookSettings.viewMode != mode) { final ActionDialogBuilder builder = new ActionDialogBuilder(getContext(), this); builder.setTitle(android.R.string.dialog_alert_title); builder.setMessage(R.string.error_invalid_view_mode, mode.getResValue()); builder.setNegativeButton(); builder.show(); return; } ViewEffects.toggleControls(view); if (view instanceof ManualCropView) { final ManualCropView mcv = (ManualCropView) view; if (mcv.getVisibility() == View.VISIBLE) { mcv.initControls(); } } IUIManager.instance.invalidateOptionsMenu(getManagedComponent()); }
@ActionMethod(ids = R.id.actions_downloadBook) public void doDownload(final ActionEx action) { final Book book = action.getParameter("book"); final Integer index = action.getParameter(IActionController.DIALOG_ITEM_PROPERTY); if (book != null && index != null) { adapter.downloadBook(book, index.intValue()); } }
@ActionMethod(ids = {R.id.actions_doSearch, R.id.actions_doSearchBack}) public final void doSearch(final ActionEx action) { final Editable value = action.getParameter("input"); final String newPattern = (value != null ? value.toString() : LengthUtils.toString(action.getParameter("text"))); final String oldPattern = currentSearchPattern; currentSearchPattern = newPattern; executor.execute( new SearchTask(), newPattern, oldPattern, (String) action.getParameter("forward")); }
@ActionMethod(ids = R.id.actions_gotoOutlineItem) public void gotoOutlineItem(final ActionEx action) { final OutlineLink link = action.getParameter(IActionController.ADAPTER_SELECTED_ITEM_PROPERTY); if (link == null) { return; } if (link.targetPage != -1) { final int pageCount = documentModel.decodeService.getPageCount(); if (link.targetPage < 1 || link.targetPage > pageCount) { getManagedComponent().showToastText(2000, R.string.error_page_out_of_rande, pageCount); } else { getDocumentController() .goToLink( link.targetPage - 1, link.targetRect, AppSettings.current().storeOutlineGotoHistory); } return; } if (link.targetUrl != null) { final Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(link.targetUrl)); getManagedComponent().startActivity(i); } }
@ActionMethod(ids = R.id.actions_addFeed) public void addFeed(final ActionEx action) { final String alias = LengthUtils.toString(action.getParameter("alias")); final String url = LengthUtils.toString(action.getParameter("url")); if (LengthUtils.isAnyEmpty(alias, url)) { return; } final Boolean auth = action.getParameter("auth"); if (auth) { final String login = action.getParameter("login").toString(); final String password = ((PasswordEditable) action.getParameter("password")).getPassword(); adapter.addFeed(alias, url, login, password); } else { adapter.addFeed(alias, url); } }
@ActionMethod(ids = {R.id.mainmenu_force_portrait, R.id.mainmenu_force_landscape}) public void forceOrientation(final ActionEx action) { final BookRotationType mode = action.getParameter("mode"); if (bookSettings.rotation == mode) { SettingsManager.setBookRotation(bookSettings, BookRotationType.UNSPECIFIED); } else { SettingsManager.setBookRotation(bookSettings, mode); } }
@ActionMethod(ids = {R.id.opds_feed_delete}) public void showDeleteFeedDlg(final ActionEx action) { final Feed feed = action.getParameter("feed"); final ActionDialogBuilder builder = new ActionDialogBuilder(getManagedComponent(), this); builder.setTitle(R.string.opds_deletefeed_title); builder.setMessage(R.string.opds_deletefeed_msg); builder.setPositiveButton( R.string.opds_deletefeed_ok, R.id.actions_deleteFeed, new Constant("feed", feed)); builder.setNegativeButton(); builder.show(); }
@ActionMethod(ids = R.id.actions_goToBookmark) public void goToBookmark(final ActionEx action) { final Bookmark b = action.getParameter("bookmark"); if (b == null) { return; } final Page actualPage = b.page.getActualPage(getDocumentModel(), bookSettings); if (actualPage != null) { jumpToPage( actualPage.index.viewIndex, b.offsetX, b.offsetY, AppSettings.current().storeGotoHistory); } }
@ActionMethod(ids = {R.id.opds_feed_edit}) public void showEditFeedDlg(final ActionEx action) { final Feed feed = action.getParameter("feed"); final View childView = LayoutInflater.from(getManagedComponent()).inflate(R.layout.alias_url, null); final ActionDialogBuilder builder = new ActionDialogBuilder(getManagedComponent(), this); builder.setTitle(R.string.opds_editfeed_title); builder.setMessage(R.string.opds_editfeed_msg); builder.setView(childView); final EditText aliasEdit = (EditText) childView.findViewById(R.id.editAlias); final EditText urlEdit = (EditText) childView.findViewById(R.id.editURL); final CheckBox authCheck = (CheckBox) childView.findViewById(R.id.checkAuth); final TextView loginText = (TextView) childView.findViewById(R.id.textUsername); final EditText loginEdit = (EditText) childView.findViewById(R.id.editUsername); final TextView passwordText = (TextView) childView.findViewById(R.id.textPassword); final EditText passwordEdit = (EditText) childView.findViewById(R.id.editPassword); authCheck.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { loginText.setVisibility(isChecked ? View.VISIBLE : View.GONE); loginEdit.setVisibility(isChecked ? View.VISIBLE : View.GONE); passwordText.setVisibility(isChecked ? View.VISIBLE : View.GONE); passwordEdit.setVisibility(isChecked ? View.VISIBLE : View.GONE); } }); authCheck.setChecked(feed.login == null); authCheck.setChecked(feed.login != null); aliasEdit.setText(feed.title); urlEdit.setText(feed.id); loginEdit.setText(feed.login); passwordEdit.setText(feed.password); builder.setPositiveButton( R.string.opds_editfeed_ok, R.id.actions_editFeed, new EditableValue("alias", aliasEdit), new EditableValue("url", urlEdit), new CheckableValue("auth", authCheck), new EditableValue("login", loginEdit), new EditableValue("password", passwordEdit), new Constant("feed", feed)); builder.setNegativeButton(); builder.show(); }
@ActionMethod(ids = R.id.actions_addBookmark) public void addBookmark(final ActionEx action) { final Editable value = action.getParameter("input"); final String name = value.toString(); final Page page = documentModel.getCurrentPageObject(); if (page != null) { final ViewState state = ViewState.get(getDocumentController()); final PointF pos = state.getPositionOnPage(page); bookSettings.bookmarks.add(new Bookmark(name, documentModel.getCurrentIndex(), pos.x, pos.y)); Collections.sort(bookSettings.bookmarks); SettingsManager.storeBookSettings(bookSettings); IUIManager.instance.invalidateOptionsMenu(getManagedComponent()); state.release(); } }
@ActionMethod(ids = R.id.actions_doSaveAndClose) public void doSaveAndClose(final ActionEx action) { final File targetFolder = action.getParameter(FolderDlg.SELECTED_FOLDER); final File source = new File(m_fileName); final File target = new File(targetFolder, source.getName()); try { FileUtils.copy(source, target); SettingsManager.copyBookSettings(target, bookSettings); CacheManager.copy(source.getAbsolutePath(), target.getAbsolutePath(), true); } catch (final IOException ex) { ex.printStackTrace(); } doClose(action); }
@ActionMethod(ids = R.id.actions_editFeed) public void editFeed(final ActionEx action) { final Feed feed = action.getParameter("feed"); final String alias = LengthUtils.toString(action.getParameter("alias")); final String url = LengthUtils.toString(action.getParameter("url")); final Boolean auth = action.getParameter("auth"); final String login = auth ? action.getParameter("login").toString() : null; final String password = auth ? ((PasswordEditable) action.getParameter("password")).getPassword() : null; if (LengthUtils.isAllNotEmpty(alias, url)) { adapter.editFeed(feed, alias, url, login, password); } }
@ActionMethod(ids = R.id.opds_book_download) public void showDownloadDlg(final ActionEx action) { final Book book = action.getParameter("book"); final Link link = action.getParameter("link"); showDownloadDlg(book, link); }
@ActionMethod(ids = R.id.actions_deleteFeed) public void deleteFeed(final ActionEx action) { final Feed feed = action.getParameter("feed"); adapter.removeFeed(feed); }
@ActionMethod(ids = R.id.opdsgoto) public void goTo(final ActionEx action) { final Feed feed = action.getParameter("feed"); setCurrentFeed(feed); }
@ActionMethod(ids = R.id.actions_redecodingWithPassword) public void redecodingWithPassword(final ActionEx action) { final PasswordEditable value = action.getParameter("input"); final String password = value.getPassword(); startDecoding(password); }