use of com.ichi2.anki.dialogs.IntegerDialog in project AnkiChinaAndroid by ankichinateam.
the class NoteEditor method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == android.R.id.home) {
Timber.i("NoteEditor:: Home button pressed");
closeCardEditorWithCheck();
return true;
} else if (itemId == R.id.action_preview) {
Timber.i("NoteEditor:: Preview button pressed");
performPreview();
return true;
} else if (itemId == R.id.action_save) {
Timber.i("NoteEditor:: Save note button pressed");
saveNote();
return true;
} else if (itemId == R.id.action_add_note_from_note_editor) {
Timber.i("NoteEditor:: Add Note button pressed");
addNewNote();
return true;
} else if (itemId == R.id.action_copy_note) {
Timber.i("NoteEditor:: Copy Note button pressed");
copyNote();
return true;
} else if (itemId == R.id.action_font_size) {
Timber.i("NoteEditor:: Font Size button pressed");
IntegerDialog repositionDialog = new IntegerDialog();
repositionDialog.setArgs(getString(R.string.menu_font_size), getEditTextFontSize(), 2);
repositionDialog.setCallbackRunnable(this::setFontSize);
showDialogFragment(repositionDialog);
return true;
} else if (itemId == R.id.action_show_toolbar) {
item.setChecked(!item.isChecked());
AnkiDroidApp.getSharedPrefs(this).edit().putBoolean("noteEditorShowToolbar", item.isChecked()).apply();
updateToolbar();
} else if (itemId == R.id.action_capitalize) {
Timber.i("NoteEditor:: Capitalize button pressed. New State: %b", !item.isChecked());
// Needed for Android 9
item.setChecked(!item.isChecked());
toggleCapitalize(item.isChecked());
return true;
}
return super.onOptionsItemSelected(item);
}
use of com.ichi2.anki.dialogs.IntegerDialog in project Anki-Android by ankidroid.
the class NoteEditor method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == android.R.id.home) {
Timber.i("NoteEditor:: Home button pressed");
closeCardEditorWithCheck();
return true;
} else if (itemId == R.id.action_preview) {
Timber.i("NoteEditor:: Preview button pressed");
performPreview();
return true;
} else if (itemId == R.id.action_save) {
Timber.i("NoteEditor:: Save note button pressed");
saveNote();
return true;
} else if (itemId == R.id.action_add_note_from_note_editor) {
Timber.i("NoteEditor:: Add Note button pressed");
addNewNote();
return true;
} else if (itemId == R.id.action_copy_note) {
Timber.i("NoteEditor:: Copy Note button pressed");
copyNote();
return true;
} else if (itemId == R.id.action_font_size) {
Timber.i("NoteEditor:: Font Size button pressed");
IntegerDialog repositionDialog = new IntegerDialog();
repositionDialog.setArgs(getString(R.string.menu_font_size), getEditTextFontSize(), 2);
repositionDialog.setCallbackRunnable(this::setFontSize);
showDialogFragment(repositionDialog);
return true;
} else if (itemId == R.id.action_show_toolbar) {
item.setChecked(!item.isChecked());
AnkiDroidApp.getSharedPrefs(this).edit().putBoolean("noteEditorShowToolbar", item.isChecked()).apply();
updateToolbar();
} else if (itemId == R.id.action_capitalize) {
Timber.i("NoteEditor:: Capitalize button pressed. New State: %b", !item.isChecked());
// Needed for Android 9
item.setChecked(!item.isChecked());
toggleCapitalize(item.isChecked());
return true;
} else if (itemId == R.id.action_scroll_toolbar) {
item.setChecked(!item.isChecked());
AnkiDroidApp.getSharedPrefs(this).edit().putBoolean("noteEditorScrollToolbar", item.isChecked()).apply();
updateToolbar();
}
return super.onOptionsItemSelected(item);
}
use of com.ichi2.anki.dialogs.IntegerDialog in project AnkiChinaAndroid by ankichinateam.
the class SelfStudyActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// (when another operation will be performed on the model, it will undo the latest operation)
if (mUndoSnackbar != null && mUndoSnackbar.isShown()) {
mUndoSnackbar.dismiss();
}
switch(item.getItemId()) {
case android.R.id.home:
endMultiSelectMode();
return true;
case R.id.screen:
showScreenDialog();
return true;
case R.id.action_edit:
mCardsAdapter.setMultiCheckable(!mCardsAdapter.isMultiCheckableMode());
return true;
case R.id.action_add_note_from_card_browser:
{
Intent intent = new Intent(SelfStudyActivity.this, NoteEditor.class);
intent.putExtra(NoteEditor.EXTRA_CALLER, NoteEditor.CALLER_CARDBROWSER_ADD);
startActivityForResultWithAnimation(intent, ADD_NOTE, ActivityTransitionAnimation.LEFT);
return true;
}
case R.id.action_save_search:
{
String searchTerms = mSearchView.getQuery().toString();
showDialogFragment(CardBrowserMySearchesDialog.newInstance(null, mMySearchesDialogListener, searchTerms, CardBrowserMySearchesDialog.CARD_BROWSER_MY_SEARCHES_TYPE_SAVE));
return true;
}
case R.id.action_list_my_searches:
{
JSONObject savedFiltersObj = getCol().getConf().optJSONObject("savedFilters");
HashMap<String, String> savedFilters = new HashMap<>();
if (savedFiltersObj != null) {
Iterator<String> it = savedFiltersObj.keys();
while (it.hasNext()) {
String searchName = it.next();
savedFilters.put(searchName, savedFiltersObj.optString(searchName));
}
}
showDialogFragment(CardBrowserMySearchesDialog.newInstance(savedFilters, mMySearchesDialogListener, "", CardBrowserMySearchesDialog.CARD_BROWSER_MY_SEARCHES_TYPE_LIST));
return true;
}
case R.id.action_sort_by_size:
showDialogFragment(CardBrowserOrderDialog.newInstance(mOrder, mOrderAsc, mOrderDialogListener));
return true;
case R.id.action_show_marked:
mSearchTerms = "tag:marked";
mSearchView.setQuery("", false);
mSearchView.setQueryHint(getResources().getString(R.string.card_browser_show_marked));
searchCards();
return true;
case R.id.action_show_suspended:
mSearchTerms = "is:suspended";
mSearchView.setQuery("", false);
mSearchView.setQueryHint(getResources().getString(R.string.card_browser_show_suspended));
searchCards();
return true;
case R.id.action_flag_zero:
flagTask(0);
return true;
case R.id.action_flag_one:
flagTask(1);
return true;
case R.id.action_flag_two:
flagTask(2);
return true;
case R.id.action_flag_three:
flagTask(3);
return true;
case R.id.action_flag_four:
flagTask(4);
return true;
case R.id.action_delete_card:
if (inMultiSelectMode()) {
CollectionTask.launchCollectionTask(DISMISS_MULTI, mDeleteNoteHandler, new TaskData(new Object[] { getSelectedCardIds(), Collection.DismissType.DELETE_NOTE_MULTI }));
mCardsAdapter.getSelectedItemIds().clear();
}
return true;
case R.id.action_mark_card:
CollectionTask.launchCollectionTask(DISMISS_MULTI, markCardHandler(), new TaskData(new Object[] { getSelectedCardIds(), Collection.DismissType.MARK_NOTE_MULTI }));
return true;
case R.id.action_suspend_card:
CollectionTask.launchCollectionTask(DISMISS_MULTI, suspendCardHandler(), new TaskData(new Object[] { getSelectedCardIds(), Collection.DismissType.SUSPEND_CARD_MULTI }));
toggleMultiSelectMode(false);
return true;
case R.id.action_change_deck:
{
AlertDialog.Builder builderSingle = new AlertDialog.Builder(this);
builderSingle.setTitle(getString(R.string.move_all_to_deck));
// WARNING: changeDeck depends on this index, so any changes should be reflected there.
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.dropdown_deck_item);
for (Deck deck : getValidDecksForChangeDeck()) {
try {
arrayAdapter.add(deck.getString("name"));
} catch (JSONException e) {
e.printStackTrace();
}
}
builderSingle.setNegativeButton(getString(R.string.cancel), (dialog, which) -> dialog.dismiss());
builderSingle.setAdapter(arrayAdapter, (dialog, which) -> changeDeck(which));
builderSingle.show();
return true;
}
case R.id.action_undo:
if (getCol().undoAvailable()) {
CollectionTask.launchCollectionTask(UNDO, mUndoHandler);
}
return true;
case R.id.action_preview:
{
mStartStudyButton.performClick();
return true;
}
case R.id.action_reset_cards_progress:
{
Timber.i("NoteEditor:: Reset progress button pressed");
// Show confirmation dialog before resetting card progress
ConfirmationDialog dialog = new ConfirmationDialog();
String title = getString(R.string.reset_card_dialog_title);
String message = getString(R.string.reset_card_dialog_message);
dialog.setArgs(title, message);
Runnable confirm = () -> {
Timber.i("CardBrowser:: ResetProgress button pressed");
CollectionTask.launchCollectionTask(DISMISS_MULTI, resetProgressCardHandler(), new TaskData(new Object[] { getSelectedCardIds(), Collection.DismissType.RESET_CARDS }));
};
dialog.setConfirm(confirm);
showDialogFragment(dialog);
return true;
}
case R.id.action_reschedule_cards:
{
Timber.i("CardBrowser:: Reschedule button pressed");
long[] selectedCardIds = getSelectedCardIds();
FunctionalInterfaces.Consumer<Integer> consumer = newDays -> CollectionTask.launchCollectionTask(DISMISS_MULTI, rescheduleCardHandler(), new TaskData(new Object[] { selectedCardIds, Collection.DismissType.RESCHEDULE_CARDS, newDays }));
RescheduleDialog rescheduleDialog;
if (selectedCardIds.length == 1) {
long cardId = selectedCardIds[0];
Card selected = getCol().getCard(cardId);
rescheduleDialog = RescheduleDialog.rescheduleSingleCard(getResources(), selected, consumer);
} else {
rescheduleDialog = RescheduleDialog.rescheduleMultipleCards(getResources(), consumer, selectedCardIds.length);
}
showDialogFragment(rescheduleDialog);
return true;
}
case R.id.action_reposition_cards:
{
Timber.i("CardBrowser:: Reposition button pressed");
// Only new cards may be repositioned
long[] cardIds = getSelectedCardIds();
for (int i = 0; i < cardIds.length; i++) {
if (getCol().getCard(cardIds[i]).getQueue() != Consts.CARD_TYPE_NEW) {
SimpleMessageDialog dialog = SimpleMessageDialog.newInstance(getString(R.string.vague_error), getString(R.string.reposition_card_not_new_error), false);
showDialogFragment(dialog);
return false;
}
}
IntegerDialog repositionDialog = new IntegerDialog();
repositionDialog.setArgs(getString(R.string.reposition_card_dialog_title), getString(R.string.reposition_card_dialog_message), 5);
repositionDialog.setCallbackRunnable(days -> CollectionTask.launchCollectionTask(DISMISS_MULTI, repositionCardHandler(), new TaskData(new Object[] { cardIds, Collection.DismissType.REPOSITION_CARDS, days })));
showDialogFragment(repositionDialog);
return true;
}
case R.id.action_edit_note:
{
openNoteEditorForCurrentlySelectedNote();
}
default:
return super.onOptionsItemSelected(item);
}
}
use of com.ichi2.anki.dialogs.IntegerDialog in project AnkiChinaAndroid by ankichinateam.
the class CardBrowser method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// (when another operation will be performed on the model, it will undo the latest operation)
if (mUndoSnackbar != null && mUndoSnackbar.isShown()) {
mUndoSnackbar.dismiss();
}
switch(item.getItemId()) {
case android.R.id.home:
endMultiSelectMode();
return true;
case R.id.action_add_note_from_card_browser:
{
Intent intent = new Intent(CardBrowser.this, NoteEditor.class);
intent.putExtra(NoteEditor.EXTRA_CALLER, NoteEditor.CALLER_CARDBROWSER_ADD);
startActivityForResultWithAnimation(intent, ADD_NOTE, ActivityTransitionAnimation.LEFT);
return true;
}
case R.id.action_save_search:
{
String searchTerms = mSearchView.getQuery().toString();
showDialogFragment(CardBrowserMySearchesDialog.newInstance(null, mMySearchesDialogListener, searchTerms, CardBrowserMySearchesDialog.CARD_BROWSER_MY_SEARCHES_TYPE_SAVE));
return true;
}
case R.id.action_list_my_searches:
{
JSONObject savedFiltersObj = getCol().getConf().optJSONObject("savedFilters");
HashMap<String, String> savedFilters = new HashMap<>();
if (savedFiltersObj != null) {
Iterator<String> it = savedFiltersObj.keys();
while (it.hasNext()) {
String searchName = it.next();
savedFilters.put(searchName, savedFiltersObj.optString(searchName));
}
}
showDialogFragment(CardBrowserMySearchesDialog.newInstance(savedFilters, mMySearchesDialogListener, "", CardBrowserMySearchesDialog.CARD_BROWSER_MY_SEARCHES_TYPE_LIST));
return true;
}
case R.id.action_sort_by_size:
showDialogFragment(CardBrowserOrderDialog.newInstance(mOrder, mOrderAsc, mOrderDialogListener));
return true;
case R.id.action_show_marked:
mSearchTerms = "tag:marked";
mSearchView.setQuery("", false);
mSearchView.setQueryHint(getResources().getString(R.string.card_browser_show_marked));
searchCards();
return true;
case R.id.action_show_suspended:
mSearchTerms = "is:suspended";
mSearchView.setQuery("", false);
mSearchView.setQueryHint(getResources().getString(R.string.card_browser_show_suspended));
searchCards();
return true;
case R.id.action_search_by_tag:
showTagsDialog();
return true;
case R.id.action_flag_zero:
flagTask(0);
return true;
case R.id.action_flag_one:
flagTask(1);
return true;
case R.id.action_flag_two:
flagTask(2);
return true;
case R.id.action_flag_three:
flagTask(3);
return true;
case R.id.action_flag_four:
flagTask(4);
return true;
case R.id.action_delete_card:
if (mInMultiSelectMode) {
CollectionTask.launchCollectionTask(DISMISS_MULTI, mDeleteNoteHandler, new TaskData(new Object[] { getSelectedCardIds(), Collection.DismissType.DELETE_NOTE_MULTI }));
mCheckedCards.clear();
endMultiSelectMode();
mCardsAdapter.notifyDataSetChanged();
}
return true;
case R.id.action_mark_card:
CollectionTask.launchCollectionTask(DISMISS_MULTI, markCardHandler(), new TaskData(new Object[] { getSelectedCardIds(), Collection.DismissType.MARK_NOTE_MULTI }));
return true;
case R.id.action_suspend_card:
CollectionTask.launchCollectionTask(DISMISS_MULTI, suspendCardHandler(), new TaskData(new Object[] { getSelectedCardIds(), Collection.DismissType.SUSPEND_CARD_MULTI }));
return true;
case R.id.action_change_deck:
{
AlertDialog.Builder builderSingle = new AlertDialog.Builder(this);
builderSingle.setTitle(getString(R.string.move_all_to_deck));
// WARNING: changeDeck depends on this index, so any changes should be reflected there.
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.dropdown_deck_item);
for (Deck deck : getValidDecksForChangeDeck()) {
try {
arrayAdapter.add(deck.getString("name"));
} catch (JSONException e) {
e.printStackTrace();
}
}
builderSingle.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
changeDeck(which);
}
});
builderSingle.show();
return true;
}
case R.id.action_undo:
if (getCol().undoAvailable()) {
CollectionTask.launchCollectionTask(UNDO, mUndoHandler);
}
return true;
case R.id.action_select_none:
onSelectNone();
return true;
case R.id.action_select_all:
onSelectAll();
return true;
case R.id.action_preview:
{
Intent previewer = new Intent(CardBrowser.this, Previewer.class);
if (mInMultiSelectMode && checkedCardCount() > 1) {
// Multiple cards have been explicitly selected, so preview only those cards
previewer.putExtra("index", 0);
previewer.putExtra("cardList", getSelectedCardIds());
} else {
// Preview all cards, starting from the one that is currently selected
int startIndex = mCheckedCards.isEmpty() ? 0 : mCheckedCards.iterator().next().getPosition();
previewer.putExtra("index", startIndex);
previewer.putExtra("cardList", getAllCardIds());
}
startActivityForResultWithoutAnimation(previewer, PREVIEW_CARDS);
return true;
}
case R.id.action_reset_cards_progress:
{
Timber.i("NoteEditor:: Reset progress button pressed");
// Show confirmation dialog before resetting card progress
ConfirmationDialog dialog = new ConfirmationDialog();
String title = getString(R.string.reset_card_dialog_title);
String message = getString(R.string.reset_card_dialog_message);
dialog.setArgs(title, message);
Runnable confirm = () -> {
Timber.i("CardBrowser:: ResetProgress button pressed");
CollectionTask.launchCollectionTask(DISMISS_MULTI, resetProgressCardHandler(), new TaskData(new Object[] { getSelectedCardIds(), Collection.DismissType.RESET_CARDS }));
};
dialog.setConfirm(confirm);
showDialogFragment(dialog);
return true;
}
case R.id.action_reschedule_cards:
{
Timber.i("CardBrowser:: Reschedule button pressed");
long[] selectedCardIds = getSelectedCardIds();
FunctionalInterfaces.Consumer<Integer> consumer = newDays -> CollectionTask.launchCollectionTask(DISMISS_MULTI, rescheduleCardHandler(), new TaskData(new Object[] { selectedCardIds, Collection.DismissType.RESCHEDULE_CARDS, newDays }));
RescheduleDialog rescheduleDialog;
if (selectedCardIds.length == 1) {
long cardId = selectedCardIds[0];
Card selected = getCol().getCard(cardId);
rescheduleDialog = RescheduleDialog.rescheduleSingleCard(getResources(), selected, consumer);
} else {
rescheduleDialog = RescheduleDialog.rescheduleMultipleCards(getResources(), consumer, selectedCardIds.length);
}
showDialogFragment(rescheduleDialog);
return true;
}
case R.id.action_reposition_cards:
{
Timber.i("CardBrowser:: Reposition button pressed");
// Only new cards may be repositioned
long[] cardIds = getSelectedCardIds();
for (int i = 0; i < cardIds.length; i++) {
if (getCol().getCard(cardIds[i]).getQueue() != Consts.CARD_TYPE_NEW) {
SimpleMessageDialog dialog = SimpleMessageDialog.newInstance(getString(R.string.vague_error), getString(R.string.reposition_card_not_new_error), false);
showDialogFragment(dialog);
return false;
}
}
IntegerDialog repositionDialog = new IntegerDialog();
repositionDialog.setArgs(getString(R.string.reposition_card_dialog_title), getString(R.string.reposition_card_dialog_message), 5);
repositionDialog.setCallbackRunnable(days -> CollectionTask.launchCollectionTask(DISMISS_MULTI, repositionCardHandler(), new TaskData(new Object[] { cardIds, Collection.DismissType.REPOSITION_CARDS, days })));
showDialogFragment(repositionDialog);
return true;
}
case R.id.action_edit_note:
{
openNoteEditorForCurrentlySelectedNote();
}
default:
return super.onOptionsItemSelected(item);
}
}
use of com.ichi2.anki.dialogs.IntegerDialog in project Anki-Android by ankidroid.
the class CardBrowser method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (getDrawerToggle().onOptionsItemSelected(item)) {
return true;
}
// (when another operation will be performed on the model, it will undo the latest operation)
if (mUndoSnackbar != null && mUndoSnackbar.isShown())
mUndoSnackbar.dismiss();
int itemId = item.getItemId();
if (itemId == android.R.id.home) {
endMultiSelectMode();
return true;
} else if (itemId == R.id.action_add_note_from_card_browser) {
addNoteFromCardBrowser();
return true;
} else if (itemId == R.id.action_save_search) {
String searchTerms = mSearchView.getQuery().toString();
showDialogFragment(CardBrowserMySearchesDialog.newInstance(null, mMySearchesDialogListener, searchTerms, CardBrowserMySearchesDialog.CARD_BROWSER_MY_SEARCHES_TYPE_SAVE));
return true;
} else if (itemId == R.id.action_list_my_searches) {
JSONObject savedFiltersObj = getCol().get_config("savedFilters", (JSONObject) null);
HashMap<String, String> savedFilters;
if (savedFiltersObj != null) {
savedFilters = HashUtil.HashMapInit(savedFiltersObj.length());
for (String searchName : savedFiltersObj) {
savedFilters.put(searchName, savedFiltersObj.optString(searchName));
}
} else {
savedFilters = HashUtil.HashMapInit(0);
}
showDialogFragment(CardBrowserMySearchesDialog.newInstance(savedFilters, mMySearchesDialogListener, "", CardBrowserMySearchesDialog.CARD_BROWSER_MY_SEARCHES_TYPE_LIST));
return true;
} else if (itemId == R.id.action_sort_by_size) {
showDialogFragment(CardBrowserOrderDialog.newInstance(mOrder, mOrderAsc, mOrderDialogListener));
return true;
} else if (itemId == R.id.action_show_marked) {
mSearchTerms = "tag:marked";
mSearchView.setQuery("", false);
mSearchView.setQueryHint(getResources().getString(R.string.card_browser_show_marked));
searchCards();
return true;
} else if (itemId == R.id.action_show_suspended) {
mSearchTerms = "is:suspended";
mSearchView.setQuery("", false);
mSearchView.setQueryHint(getResources().getString(R.string.card_browser_show_suspended));
searchCards();
return true;
} else if (itemId == R.id.action_search_by_tag) {
showFilterByTagsDialog();
return true;
} else if (itemId == R.id.action_flag_zero) {
flagTask(0);
return true;
} else if (itemId == R.id.action_flag_one) {
flagTask(1);
return true;
} else if (itemId == R.id.action_flag_two) {
flagTask(2);
return true;
} else if (itemId == R.id.action_flag_three) {
flagTask(3);
return true;
} else if (itemId == R.id.action_flag_four) {
flagTask(4);
return true;
} else if (itemId == R.id.action_flag_five) {
flagTask(5);
return true;
} else if (itemId == R.id.action_flag_six) {
flagTask(6);
return true;
} else if (itemId == R.id.action_flag_seven) {
flagTask(7);
return true;
} else if (itemId == R.id.action_select_flag_zero) {
selectionWithFlagTask(0);
return true;
} else if (itemId == R.id.action_select_flag_one) {
selectionWithFlagTask(1);
return true;
} else if (itemId == R.id.action_select_flag_two) {
selectionWithFlagTask(2);
return true;
} else if (itemId == R.id.action_select_flag_three) {
selectionWithFlagTask(3);
return true;
} else if (itemId == R.id.action_select_flag_four) {
selectionWithFlagTask(4);
return true;
} else if (itemId == R.id.action_select_flag_five) {
selectionWithFlagTask(5);
return true;
} else if (itemId == R.id.action_select_flag_six) {
selectionWithFlagTask(6);
return true;
} else if (itemId == R.id.action_select_flag_seven) {
selectionWithFlagTask(7);
return true;
} else if (itemId == R.id.action_delete_card) {
deleteSelectedNote();
return true;
} else if (itemId == R.id.action_mark_card) {
toggleMark();
return true;
} else if (itemId == R.id.action_suspend_card) {
TaskManager.launchCollectionTask(new CollectionTask.SuspendCardMulti(getSelectedCardIds()), suspendCardHandler());
return true;
} else if (itemId == R.id.action_change_deck) {
showChangeDeckDialog();
return true;
} else if (itemId == R.id.action_undo) {
Timber.w("CardBrowser:: Undo pressed");
onUndo();
return true;
} else if (itemId == R.id.action_select_none) {
onSelectNone();
return true;
} else if (itemId == R.id.action_select_all) {
onSelectAll();
return true;
} else if (itemId == R.id.action_preview) {
onPreview();
return true;
} else if (itemId == R.id.action_reset_cards_progress) {
Timber.i("NoteEditor:: Reset progress button pressed");
onResetProgress();
return true;
} else if (itemId == R.id.action_reschedule_cards) {
Timber.i("CardBrowser:: Reschedule button pressed");
rescheduleSelectedCards();
return true;
} else if (itemId == R.id.action_reposition_cards) {
Timber.i("CardBrowser:: Reposition button pressed");
// Only new cards may be repositioned
List<Long> cardIds = getSelectedCardIds();
for (long cardId : cardIds) {
if (getCol().getCard(cardId).getQueue() != Consts.QUEUE_TYPE_NEW) {
SimpleMessageDialog dialog = SimpleMessageDialog.newInstance(getString(R.string.vague_error), getString(R.string.reposition_card_not_new_error), false);
showDialogFragment(dialog);
return false;
}
}
IntegerDialog repositionDialog = new IntegerDialog();
repositionDialog.setArgs(getString(R.string.reposition_card_dialog_title), getString(R.string.reposition_card_dialog_message), 5);
repositionDialog.setCallbackRunnable(position -> repositionCardsNoValidation(cardIds, position));
showDialogFragment(repositionDialog);
return true;
} else if (itemId == R.id.action_edit_note) {
openNoteEditorForCurrentlySelectedNote();
return super.onOptionsItemSelected(item);
} else if (itemId == R.id.action_view_card_info) {
List<Long> selectedCardIds = getSelectedCardIds();
if (!selectedCardIds.isEmpty()) {
Intent intent = new Intent(this, CardInfo.class);
intent.putExtra("cardId", selectedCardIds.get(0));
startActivityWithAnimation(intent, FADE);
}
return true;
} else if (itemId == R.id.action_edit_tags) {
showEditTagsDialog();
}
return super.onOptionsItemSelected(item);
}
Aggregations