Search in sources :

Example 6 with TagsDialog

use of com.ichi2.anki.dialogs.TagsDialog in project AnkiChinaAndroid by ankichinateam.

the class SelfStudyActivity method showTagsDialog.

private void showTagsDialog(TextView tag_selected) {
    TagsDialog dialog = TagsDialog.newInstance(TagsDialog.TYPE_FILTER_BY_TAG, new ArrayList<>(), new ArrayList<>(getCol().getTags().all()));
    dialog.setTagsDialogListener((selectedTags, option) -> filterByTag(selectedTags, option, tag_selected));
    showDialogFragment(dialog);
}
Also used : TagsDialog(com.ichi2.anki.dialogs.TagsDialog)

Example 7 with TagsDialog

use of com.ichi2.anki.dialogs.TagsDialog in project AnkiChinaAndroid by ankichinateam.

the class CustomStudyDialog method buildContextMenu.

/**
 * Build a context menu for custom study
 *
 * @param id
 * @return
 */
private MaterialDialog buildContextMenu(int id) {
    int[] listIds = getListIds(id);
    final boolean jumpToReviewer = getArguments().getBoolean("jumpToReviewer");
    return new MaterialDialog.Builder(this.getActivity()).title(R.string.custom_study).cancelable(true).itemsIds(listIds).items(ContextMenuHelper.getValuesFromKeys(getKeyValueMap(), listIds)).itemsCallback(new MaterialDialog.ListCallback() {

        @Override
        public void onSelection(MaterialDialog materialDialog, View view, int which, CharSequence charSequence) {
            AnkiActivity activity = getAnkiActivity();
            switch(view.getId()) {
                case DECK_OPTIONS:
                    {
                        // User asked to permanently change the deck options
                        Intent i = new Intent(activity, DeckOptions.class);
                        i.putExtra("did", getArguments().getLong("did"));
                        getActivity().startActivity(i);
                        break;
                    }
                case MORE_OPTIONS:
                    {
                        // User asked to see all custom study options
                        CustomStudyDialog d = CustomStudyDialog.newInstance(CONTEXT_MENU_STANDARD, getArguments().getLong("did"), jumpToReviewer, listener);
                        activity.showDialogFragment(d);
                        break;
                    }
                case CUSTOM_STUDY_TAGS:
                    {
                        /*
                                 * This is a special Dialog for CUSTOM STUDY, where instead of only collecting a
                                 * number, it is necessary to collect a list of tags. This case handles the creation
                                 * of that Dialog.
                                 */
                        long currentDeck = getArguments().getLong("did");
                        TagsDialog dialogFragment = TagsDialog.newInstance(TagsDialog.TYPE_CUSTOM_STUDY_TAGS, new ArrayList<String>(), new ArrayList<>(activity.getCol().getTags().byDeck(currentDeck, true)));
                        dialogFragment.setTagsDialogListener(CustomStudyDialog.this::customStudyFromTags);
                        activity.showDialogFragment(dialogFragment);
                        break;
                    }
                default:
                    {
                        // User asked for a standard custom study option
                        CustomStudyDialog d = CustomStudyDialog.newInstance(view.getId(), getArguments().getLong("did"), jumpToReviewer, listener);
                        getAnkiActivity().showDialogFragment(d);
                    }
            }
        }
    }).build();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ArrayList(java.util.ArrayList) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) AnkiActivity(com.ichi2.anki.AnkiActivity) DeckOptions(com.ichi2.anki.DeckOptions)

Example 8 with TagsDialog

use of com.ichi2.anki.dialogs.TagsDialog in project Anki-Android by ankidroid.

the class NoteEditor method showTagsDialog.

private void showTagsDialog() {
    if (mSelectedTags == null) {
        mSelectedTags = new ArrayList<>(0);
    }
    ArrayList<String> tags = new ArrayList<>(getCol().getTags().all());
    ArrayList<String> selTags = new ArrayList<>(mSelectedTags);
    TagsDialog dialog = mTagsDialogFactory.newTagsDialog().withArguments(TagsDialog.DialogType.EDIT_TAGS, selTags, tags);
    showDialogFragment(dialog);
}
Also used : ArrayList(java.util.ArrayList) TagsDialog(com.ichi2.anki.dialogs.tags.TagsDialog)

Example 9 with TagsDialog

use of com.ichi2.anki.dialogs.TagsDialog in project Anki-Android by ankidroid.

the class AbstractFlashcardViewer method showTagsDialog.

protected void showTagsDialog() {
    ArrayList<String> tags = new ArrayList<>(getCol().getTags().all());
    ArrayList<String> selTags = new ArrayList<>(mCurrentCard.note().getTags());
    TagsDialog dialog = mTagsDialogFactory.newTagsDialog().withArguments(TagsDialog.DialogType.EDIT_TAGS, selTags, tags);
    showDialogFragment(dialog);
}
Also used : ArrayList(java.util.ArrayList) TagsDialog(com.ichi2.anki.dialogs.tags.TagsDialog)

Aggregations

ArrayList (java.util.ArrayList)6 Intent (android.content.Intent)4 View (android.view.View)4 TextView (android.widget.TextView)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4 TagsDialog (com.ichi2.anki.dialogs.TagsDialog)4 BroadcastReceiver (android.content.BroadcastReceiver)3 Context (android.content.Context)3 IntentFilter (android.content.IntentFilter)3 SharedPreferences (android.content.SharedPreferences)3 Bundle (android.os.Bundle)3 TextUtils (android.text.TextUtils)3 Pair (android.util.Pair)3 KeyEvent (android.view.KeyEvent)3 Menu (android.view.Menu)3 MenuItem (android.view.MenuItem)3 WindowManager (android.view.WindowManager)3 CheckResult (androidx.annotation.CheckResult)3 NonNull (androidx.annotation.NonNull)3 Nullable (androidx.annotation.Nullable)3