Search in sources :

Example 1 with ReadingList

use of org.wikipedia.readinglist.database.ReadingList in project apps-android-wikipedia by wikimedia.

the class AddToReadingListDialog method showCreateListDialog.

private void showCreateListDialog() {
    String title = getString(R.string.reading_list_name_sample);
    List<String> existingTitles = new ArrayList<>();
    for (ReadingList tempList : readingLists) {
        existingTitles.add(tempList.title());
    }
    ReadingListTitleDialog.readingListTitleDialog(requireContext(), title, "", existingTitles, (text, description) -> {
        ReadingList list = ReadingListDbHelper.instance().createList(text, description);
        addAndDismiss(list, titles);
    }).show();
}
Also used : Bundle(android.os.Bundle) ReadingListsFunnel(org.wikipedia.analytics.ReadingListsFunnel) CallbackTask(org.wikipedia.concurrency.CallbackTask) ReadingList(org.wikipedia.readinglist.database.ReadingList) NonNull(android.support.annotation.NonNull) EnumCode(org.wikipedia.model.EnumCode) ArrayList(java.util.ArrayList) ExtendedBottomSheetDialogFragment(org.wikipedia.page.ExtendedBottomSheetDialogFragment) ReadingListDbHelper(org.wikipedia.readinglist.database.ReadingListDbHelper) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) SiteInfoClient(org.wikipedia.settings.SiteInfoClient) View(android.view.View) Constants(org.wikipedia.Constants) DialogInterface(android.content.DialogInterface) Parcelable(android.os.Parcelable) R(org.wikipedia.R) LayoutInflater(android.view.LayoutInflater) PageTitle(org.wikipedia.page.PageTitle) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ViewGroup(android.view.ViewGroup) Prefs(org.wikipedia.settings.Prefs) RecyclerView(android.support.v7.widget.RecyclerView) EnumCodeMap(org.wikipedia.model.EnumCodeMap) List(java.util.List) PrefsOnboardingStateMachine(org.wikipedia.onboarding.PrefsOnboardingStateMachine) Nullable(android.support.annotation.Nullable) DimenUtil(org.wikipedia.util.DimenUtil) Collections(java.util.Collections) FeedbackUtil(org.wikipedia.util.FeedbackUtil) ArrayList(java.util.ArrayList) ReadingList(org.wikipedia.readinglist.database.ReadingList)

Example 2 with ReadingList

use of org.wikipedia.readinglist.database.ReadingList in project apps-android-wikipedia by wikimedia.

the class ReadingListsFragment method showDeleteListUndoSnackbar.

private void showDeleteListUndoSnackbar(final ReadingList readingList) {
    Snackbar snackbar = FeedbackUtil.makeSnackbar(getActivity(), String.format(getString(R.string.reading_list_deleted), readingList.title()), FeedbackUtil.LENGTH_DEFAULT);
    snackbar.setAction(R.string.reading_list_item_delete_undo, v -> {
        ReadingList newList = ReadingListDbHelper.instance().createList(readingList.title(), readingList.description());
        List<ReadingListPage> newPages = new ArrayList<>();
        for (ReadingListPage page : readingList.pages()) {
            newPages.add(new ReadingListPage(ReadingListPage.toPageTitle(page)));
        }
        ReadingListDbHelper.instance().addPagesToList(newList, newPages, true);
        updateLists();
    });
    snackbar.show();
}
Also used : ArrayList(java.util.ArrayList) ReadingList(org.wikipedia.readinglist.database.ReadingList) ReadingListPage(org.wikipedia.readinglist.database.ReadingListPage) Snackbar(android.support.design.widget.Snackbar)

Example 3 with ReadingList

use of org.wikipedia.readinglist.database.ReadingList in project apps-android-wikipedia by wikimedia.

the class ReadingListsFragment method maybeDeleteListFromIntent.

private void maybeDeleteListFromIntent() {
    if (requireActivity().getIntent().hasExtra(Constants.INTENT_EXTRA_DELETE_READING_LIST)) {
        String titleToDelete = requireActivity().getIntent().getStringExtra(Constants.INTENT_EXTRA_DELETE_READING_LIST);
        requireActivity().getIntent().removeExtra(Constants.INTENT_EXTRA_DELETE_READING_LIST);
        for (ReadingList list : readingLists) {
            if (list.title().equals(titleToDelete)) {
                deleteList(list);
            }
        }
    }
}
Also used : ReadingList(org.wikipedia.readinglist.database.ReadingList)

Example 4 with ReadingList

use of org.wikipedia.readinglist.database.ReadingList in project apps-android-wikipedia by wikimedia.

the class ReadingListFragment method rename.

private void rename() {
    if (readingList == null) {
        return;
    } else if (readingList.isDefault()) {
        L.w("Attempted to rename default list.");
        return;
    }
    List<ReadingList> tempLists = ReadingListDbHelper.instance().getAllListsWithoutContents();
    List<String> existingTitles = new ArrayList<>();
    for (ReadingList list : tempLists) {
        existingTitles.add(list.title());
    }
    existingTitles.remove(readingList.title());
    ReadingListTitleDialog.readingListTitleDialog(requireContext(), readingList.title(), readingList.description(), existingTitles, (text, description) -> {
        readingList.title(text);
        readingList.description(description);
        readingList.dirty(true);
        ReadingListDbHelper.instance().updateList(readingList, true);
        update();
        funnel.logModifyList(readingList, 0);
    }).show();
}
Also used : SearchActionModeCallback(org.wikipedia.history.SearchActionModeCallback) Bundle(android.os.Bundle) ReadingListsFunnel(org.wikipedia.analytics.ReadingListsFunnel) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) CallbackTask(org.wikipedia.concurrency.CallbackTask) ReadingList(org.wikipedia.readinglist.database.ReadingList) ReadingListPage(org.wikipedia.readinglist.database.ReadingListPage) PageActivity(org.wikipedia.page.PageActivity) ShareUtil(org.wikipedia.util.ShareUtil) PageItemView(org.wikipedia.views.PageItemView) BindView(butterknife.BindView) Locale(java.util.Locale) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) StringUtil(org.wikipedia.util.StringUtil) View(android.view.View) EXTRA_READING_LIST_ID(org.wikipedia.readinglist.ReadingListActivity.EXTRA_READING_LIST_ID) Constants(org.wikipedia.Constants) SearchEmptyView(org.wikipedia.views.SearchEmptyView) Unbinder(butterknife.Unbinder) MainActivity(org.wikipedia.main.MainActivity) ActionMode(android.support.v7.view.ActionMode) Fragment(android.support.v4.app.Fragment) PageTitle(org.wikipedia.page.PageTitle) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) List(java.util.List) TextView(android.widget.TextView) L(org.wikipedia.util.log.L) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) ReadingListSyncEvent(org.wikipedia.readinglist.sync.ReadingListSyncEvent) AppBarLayout(android.support.design.widget.AppBarLayout) Spanned(android.text.Spanned) ButterKnife(butterknife.ButterKnife) NonNull(android.support.annotation.NonNull) DefaultViewHolder(org.wikipedia.views.DefaultViewHolder) SwipeableItemTouchHelperCallback(org.wikipedia.views.SwipeableItemTouchHelperCallback) HistoryEntry(org.wikipedia.history.HistoryEntry) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) ReadingListDbHelper(org.wikipedia.readinglist.database.ReadingListDbHelper) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) WikipediaApp(org.wikipedia.WikipediaApp) SiteInfoClient(org.wikipedia.settings.SiteInfoClient) Menu(android.view.Menu) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) MultiSelectActionModeCallback(org.wikipedia.views.MultiSelectActionModeCallback) R(org.wikipedia.R) LayoutInflater(android.view.LayoutInflater) PluralsRes(android.support.annotation.PluralsRes) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextUtils(android.text.TextUtils) ExclusiveBottomSheetPresenter(org.wikipedia.page.ExclusiveBottomSheetPresenter) Subscribe(com.squareup.otto.Subscribe) Prefs(org.wikipedia.settings.Prefs) Color(android.graphics.Color) RecyclerView(android.support.v7.widget.RecyclerView) AlertDialog(android.support.v7.app.AlertDialog) Toolbar(android.support.v7.widget.Toolbar) Collections(java.util.Collections) FeedbackUtil(org.wikipedia.util.FeedbackUtil) ViewUtil(org.wikipedia.views.ViewUtil) ArrayList(java.util.ArrayList) ReadingList(org.wikipedia.readinglist.database.ReadingList)

Example 5 with ReadingList

use of org.wikipedia.readinglist.database.ReadingList in project apps-android-wikipedia by wikimedia.

the class ReadingListsFragment method applySearchQuery.

@NonNull
private List<ReadingList> applySearchQuery(@Nullable String searchQuery, @NonNull List<ReadingList> lists) {
    List<ReadingList> newList = new ArrayList<>();
    if (TextUtils.isEmpty(searchQuery)) {
        newList.addAll(lists);
        return newList;
    }
    String normalizedQuery = StringUtils.stripAccents(searchQuery).toLowerCase();
    for (ReadingList list : lists) {
        if (StringUtils.stripAccents(list.title()).toLowerCase().contains(normalizedQuery)) {
            newList.add(list);
        }
    }
    return newList;
}
Also used : ArrayList(java.util.ArrayList) ReadingList(org.wikipedia.readinglist.database.ReadingList) NonNull(android.support.annotation.NonNull)

Aggregations

ReadingList (org.wikipedia.readinglist.database.ReadingList)9 ArrayList (java.util.ArrayList)7 ReadingListPage (org.wikipedia.readinglist.database.ReadingListPage)5 Bundle (android.os.Bundle)4 NonNull (android.support.annotation.NonNull)4 Nullable (android.support.annotation.Nullable)3 Snackbar (android.support.design.widget.Snackbar)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 RecyclerView (android.support.v7.widget.RecyclerView)3 LayoutInflater (android.view.LayoutInflater)3 View (android.view.View)3 ViewGroup (android.view.ViewGroup)3 List (java.util.List)3 Constants (org.wikipedia.Constants)3 R (org.wikipedia.R)3 ReadingListsFunnel (org.wikipedia.analytics.ReadingListsFunnel)3 CallbackTask (org.wikipedia.concurrency.CallbackTask)3 PageTitle (org.wikipedia.page.PageTitle)3 ReadingListDbHelper (org.wikipedia.readinglist.database.ReadingListDbHelper)3 Prefs (org.wikipedia.settings.Prefs)3