protected void showDownloadDlg(final Book book, final Link link) { if (LengthUtils.isEmpty(book.downloads)) { return; } final String rawType = getManagedComponent().getResources().getString(R.string.opds_downloading_dlg_raw_type); if (link != null || book.downloads.size() == 1) { final Link target = link != null ? link : book.downloads.get(0); final ActionDialogBuilder builder = new ActionDialogBuilder(getManagedComponent(), this); builder.setTitle(R.string.opds_downloading_dlg_title); builder.setMessage(LengthUtils.safeString(target.type, rawType)); builder.setPositiveButton( R.id.actions_downloadBook, new Constant("book", book), new Constant(IActionController.DIALOG_ITEM_PROPERTY, 0)); builder.setNegativeButton(); builder.show(); return; } final List<String> itemList = new ArrayList<String>(); for (final Link l : book.downloads) { itemList.add(LengthUtils.safeString(l.type, rawType)); } final String[] items = itemList.toArray(new String[itemList.size()]); final ActionDialogBuilder builder = new ActionDialogBuilder(getManagedComponent(), this); builder.setTitle(R.string.opds_downloading_type_dlg_title); builder.setItems(items, getOrCreateAction(R.id.actions_downloadBook).putValue("book", book)); builder.show(); }
@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()); }
public void showErrorDlg(final int msgId, final Object... args) { final ActionDialogBuilder builder = new ActionDialogBuilder(getManagedComponent(), this); builder.setTitle(R.string.error_dlg_title); builder.setMessage(msgId, args); builder.setPositiveButton(R.string.error_close, R.id.mainmenu_close); builder.show(); }
@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.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.mainmenu_close) public void closeActivity(final ActionEx action) { if (scheme == null || !scheme.temporary) { getOrCreateAction(R.id.actions_doClose).run(); return; } getOrCreateAction(R.id.actions_doSaveAndClose).putValue("save", Boolean.TRUE); getOrCreateAction(R.id.actions_doClose).putValue("save", Boolean.FALSE); final ActionDialogBuilder builder = new ActionDialogBuilder(getManagedComponent(), this); builder.setTitle(R.string.confirmclose_title); builder.setMessage(R.string.confirmsave_msg); builder.setPositiveButton(R.string.confirmsave_yes_btn, R.id.actions_showSaveDlg); builder.setNegativeButton(R.string.confirmsave_no_btn, R.id.actions_doClose); builder.show(); }