Search in sources :

Example 21 with PageTitle

use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.

the class ReadingListDbHelperTest method testFindPageForRetrievingPages.

@Test
public void testFindPageForRetrievingPages() {
    ReadingList list = readingListDbHelper.createList("Test8", "TestDesc");
    PageTitle page = new PageTitle("1", WikipediaApp.getInstance().getWikiSite());
    PageTitle page2 = new PageTitle("2", WikipediaApp.getInstance().getWikiSite());
    PageTitle page3 = new PageTitle("3", WikipediaApp.getInstance().getWikiSite());
    readingListDbHelper.addPageToList(list, page, false);
    readingListDbHelper.addPageToList(list, page2, false);
    readingListDbHelper.addPageToList(list, page3, false);
    boolean exists = readingListDbHelper.pageExistsInList(list, page);
    readingListDbHelper.deleteList(list);
    List<ReadingListPage> pages = new ArrayList<>();
    pages.add(new ReadingListPage(page));
    pages.add(new ReadingListPage(page2));
    pages.add(new ReadingListPage(page3));
    readingListDbHelper.markPagesForDeletion(list, pages);
    Assert.assertTrue(exists);
}
Also used : PageTitle(org.wikipedia.page.PageTitle) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 22 with PageTitle

use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.

the class ReadingListDbHelperTest method testGetAllPagesToBeDeletedForRetrievingPages.

@Test
public void testGetAllPagesToBeDeletedForRetrievingPages() {
    PageTitle page = new PageTitle("2", WikipediaApp.getInstance().getWikiSite());
    ReadingListPage readingListPage = new ReadingListPage(page);
    readingListPage.status(ReadingListPage.STATUS_QUEUE_FOR_DELETE);
    List<ReadingListPage> pagesListToBeAdded = new ArrayList<>();
    pagesListToBeAdded.add(readingListPage);
    ReadingList list = readingListDbHelper.createList("Test7", "TestDesc");
    readingListDbHelper.addPagesToList(list, pagesListToBeAdded, false);
    List<ReadingListPage> pagesList = readingListDbHelper.getAllPagesToBeDeleted();
    readingListDbHelper.deleteList(list);
    readingListDbHelper.markPagesForDeletion(list, pagesListToBeAdded);
    Assert.assertTrue(pagesList.size() != 0);
}
Also used : PageTitle(org.wikipedia.page.PageTitle) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 23 with PageTitle

use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.

the class ParcelableTest method testPageImage.

@Test
public void testPageImage() throws Throwable {
    WikiSite wiki = WikiSite.forLanguageCode("en");
    PageTitle title = new PageTitle("Talk", "India", wiki);
    PageImage pageImage = new PageImage(title, "Testing image");
    TestParcelUtil.test(pageImage);
}
Also used : PageTitle(org.wikipedia.page.PageTitle) PageImage(org.wikipedia.pageimages.PageImage) WikiSite(org.wikipedia.dataclient.WikiSite) Test(org.junit.Test)

Example 24 with PageTitle

use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.

the class LangLinksActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    app = WikipediaApp.getInstance();
    setStatusBarColor(ResourceUtil.getThemedAttributeId(this, R.attr.page_status_bar_color));
    setContentView(R.layout.activity_langlinks);
    if (!getIntent().getAction().equals(ACTION_LANGLINKS_FOR_TITLE)) {
        throw new RuntimeException("Only ACTION_LANGLINKS_FOR_TITLE is supported");
    }
    langLinksList = findViewById(R.id.langlinks_list);
    langLinksProgress = findViewById(R.id.langlinks_load_progress);
    langLinksContainer = findViewById(R.id.langlinks_list_container);
    langLinksEmpty = findViewById(R.id.langlinks_empty);
    langLinksNoMatch = findViewById(R.id.langlinks_no_match);
    langLinksError = findViewById(R.id.langlinks_error);
    EditText langLinksFilter = findViewById(R.id.langlinks_filter);
    title = getIntent().getParcelableExtra(EXTRA_PAGETITLE);
    if (savedInstanceState != null && savedInstanceState.containsKey(LANGUAGE_ENTRIES_BUNDLE_KEY)) {
        languageEntries = savedInstanceState.getParcelableArrayList(LANGUAGE_ENTRIES_BUNDLE_KEY);
    }
    client = new LangLinksClient();
    fetchLangLinks();
    langLinksError.setRetryClickListener((v) -> {
        ViewAnimations.crossFade(langLinksError, langLinksProgress);
        fetchLangLinks();
    });
    langLinksList.setOnItemClickListener((parent, view, position, id) -> {
        PageTitle langLink = (PageTitle) parent.getAdapter().getItem(position);
        app.setMruLanguageCode(langLink.getWikiSite().languageCode());
        HistoryEntry historyEntry = new HistoryEntry(langLink, HistoryEntry.SOURCE_LANGUAGE_LINK);
        Intent intent = PageActivity.newIntentForCurrentTab(LangLinksActivity.this, historyEntry, langLink);
        setResult(ACTIVITY_RESULT_LANGLINK_SELECT, intent);
        hideSoftKeyboard(LangLinksActivity.this);
        finish();
    });
    langLinksFilter.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            // the languages might not be loaded yet...
            if (langLinksList.getAdapter() == null) {
                return;
            }
            ((LangLinksAdapter) langLinksList.getAdapter()).setFilterText(s.toString());
            // Check if there are no languages that match the filter
            if (langLinksList.getAdapter().getCount() == 0) {
                langLinksNoMatch.setVisibility(View.VISIBLE);
            } else {
                langLinksNoMatch.setVisibility(View.GONE);
            }
        }
    });
}
Also used : EditText(android.widget.EditText) PageTitle(org.wikipedia.page.PageTitle) HistoryEntry(org.wikipedia.history.HistoryEntry) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Intent(android.content.Intent)

Example 25 with PageTitle

use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.

the class LoginActivity method onForgotPasswordClick.

@OnClick(R.id.forgot_password_link)
void onForgotPasswordClick() {
    PageTitle title = new PageTitle("Special:PasswordReset", WikipediaApp.getInstance().getWikiSite());
    visitInExternalBrowser(this, Uri.parse(title.getMobileUri()));
}
Also used : PageTitle(org.wikipedia.page.PageTitle) OnClick(butterknife.OnClick)

Aggregations

PageTitle (org.wikipedia.page.PageTitle)60 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)15 WikiSite (org.wikipedia.dataclient.WikiSite)11 HistoryEntry (org.wikipedia.history.HistoryEntry)11 NonNull (android.support.annotation.NonNull)6 OnClick (butterknife.OnClick)5 ReadingListPage (org.wikipedia.readinglist.database.ReadingListPage)5 IOException (java.io.IOException)4 Date (java.util.Date)4 WikipediaApp (org.wikipedia.WikipediaApp)3 PageBackStackItem (org.wikipedia.page.PageBackStackItem)3 Tab (org.wikipedia.page.tabs.Tab)3 ProgressDialog (android.app.ProgressDialog)2 Intent (android.content.Intent)2 AssetManager (android.content.res.AssetManager)2 Configuration (android.content.res.Configuration)2 Resources (android.content.res.Resources)2 Bundle (android.os.Bundle)2 DisplayMetrics (android.util.DisplayMetrics)2