Search in sources :

Example 11 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class OnThisDayPagesViewHolder method onBaseViewClicked.

@OnClick(R.id.parent)
void onBaseViewClicked() {
    Context context = WikipediaApp.getInstance().getApplicationContext();
    PageTitle pageTitle = new PageTitle(selectedPage.getTitle(), wiki);
    HistoryEntry entry = new HistoryEntry(pageTitle, isSingleCard ? HistoryEntry.SOURCE_ON_THIS_DAY_CARD : HistoryEntry.SOURCE_ON_THIS_DAY_ACTIVITY);
    Intent intent = new Intent(ACTION_LOAD_IN_NEW_TAB).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).setClass(context, PageActivity.class).putExtra(EXTRA_HISTORYENTRY, entry).putExtra(EXTRA_PAGETITLE, pageTitle);
    context.startActivity(intent);
}
Also used : Context(android.content.Context) PageTitle(org.wikipedia.page.PageTitle) HistoryEntry(org.wikipedia.history.HistoryEntry) Intent(android.content.Intent) OnClick(butterknife.OnClick)

Example 12 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class TabUnmarshallerTest method testUnmarshalSingle.

@Test
public void testUnmarshalSingle() {
    PageTitle page = new PageTitle("text", WikiSite.forLanguageCode("test"));
    HistoryEntry history = new HistoryEntry(page, new Date(0), HistoryEntry.SOURCE_SEARCH);
    Tab tab = new Tab();
    tab.getBackStack().add(new PageBackStackItem(page, history));
    List<Tab> tabs = singletonList(tab);
    assertThat(TabUnmarshaller.unmarshal(GsonMarshaller.marshal(tabs)), is(tabs));
}
Also used : Tab(org.wikipedia.page.tabs.Tab) PageTitle(org.wikipedia.page.PageTitle) HistoryEntry(org.wikipedia.history.HistoryEntry) PageBackStackItem(org.wikipedia.page.PageBackStackItem) Date(java.util.Date) Test(org.junit.Test)

Example 13 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class TabUnmarshallerTest method testUnmarshalNoHistoryEntryAuthority.

// T152980
@Test(expected = RuntimeException.class)
public void testUnmarshalNoHistoryEntryAuthority() {
    PageTitle page = new PageTitle("text", WikiSite.forLanguageCode("test"));
    PageTitle prevPage = new PageTitle("text", new WikiSite("", ""));
    HistoryEntry history = new HistoryEntry(prevPage, new Date(0), HistoryEntry.SOURCE_SEARCH);
    Tab tab = new Tab();
    tab.getBackStack().add(new PageBackStackItem(page, history));
    List<Tab> tabs = singletonList(tab);
    TabUnmarshaller.unmarshal(GsonMarshaller.marshal(tabs));
}
Also used : Tab(org.wikipedia.page.tabs.Tab) PageTitle(org.wikipedia.page.PageTitle) HistoryEntry(org.wikipedia.history.HistoryEntry) WikiSite(org.wikipedia.dataclient.WikiSite) PageBackStackItem(org.wikipedia.page.PageBackStackItem) Date(java.util.Date) Test(org.junit.Test)

Example 14 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class TabUnmarshallerTest method testUnmarshalNoPageTitleAuthority.

// T152980
@Test(expected = RuntimeException.class)
public void testUnmarshalNoPageTitleAuthority() {
    PageTitle page = new PageTitle("text", new WikiSite("", ""));
    HistoryEntry history = new HistoryEntry(page, new Date(0), HistoryEntry.SOURCE_SEARCH);
    Tab tab = new Tab();
    tab.getBackStack().add(new PageBackStackItem(page, history));
    List<Tab> tabs = singletonList(tab);
    TabUnmarshaller.unmarshal(GsonMarshaller.marshal(tabs));
}
Also used : Tab(org.wikipedia.page.tabs.Tab) PageTitle(org.wikipedia.page.PageTitle) HistoryEntry(org.wikipedia.history.HistoryEntry) WikiSite(org.wikipedia.dataclient.WikiSite) PageBackStackItem(org.wikipedia.page.PageBackStackItem) Date(java.util.Date) Test(org.junit.Test)

Example 15 with HistoryEntry

use of org.wikipedia.history.HistoryEntry in project apps-android-wikipedia by wikimedia.

the class LongPressHandler method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
    title = null;
    if (view instanceof WebView) {
        WebView.HitTestResult result = ((WebView) view).getHitTestResult();
        if (result.getType() == WebView.HitTestResult.SRC_ANCHOR_TYPE) {
            Uri uri = Uri.parse(result.getExtra());
            if (isValidPageLink(uri)) {
                title = ((WebViewContextMenuListener) contextMenuListener).getWikiSite().titleForInternalLink(uri.getPath());
            } else if (OfflineManager.hasCompilation() && isValidOfflinePageLink(uri)) {
                title = ((WebViewContextMenuListener) contextMenuListener).getWikiSite().titleForInternalLink(uri.getLastPathSegment().replace(".html", ""));
            }
        }
    } else if (view instanceof ListView) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        title = ((ListViewContextMenuListener) contextMenuListener).getTitleForListPosition(info.position);
    }
    if (title != null && !title.isSpecial()) {
        hideSoftKeyboard(view);
        entry = new HistoryEntry(title, historySource);
        new MenuInflater(view.getContext()).inflate(R.menu.menu_page_long_press, menu);
        menu.setHeaderTitle(title.getDisplayText());
        for (int i = 0; i < menu.size(); i++) {
            menu.getItem(i).setOnMenuItemClickListener(this);
        }
    }
}
Also used : ListView(android.widget.ListView) MenuInflater(android.view.MenuInflater) HistoryEntry(org.wikipedia.history.HistoryEntry) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) Uri(android.net.Uri)

Aggregations

HistoryEntry (org.wikipedia.history.HistoryEntry)22 PageTitle (org.wikipedia.page.PageTitle)11 WikiSite (org.wikipedia.dataclient.WikiSite)5 Date (java.util.Date)4 Test (org.junit.Test)4 PageBackStackItem (org.wikipedia.page.PageBackStackItem)3 Tab (org.wikipedia.page.tabs.Tab)3 Intent (android.content.Intent)2 Uri (android.net.Uri)2 NonNull (android.support.annotation.NonNull)2 View (android.view.View)2 WebView (android.webkit.WebView)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 OnClick (butterknife.OnClick)2 IOException (java.io.IOException)2 ObservableWebView (org.wikipedia.views.ObservableWebView)2 ProgressDialog (android.app.ProgressDialog)1 Context (android.content.Context)1 AssetManager (android.content.res.AssetManager)1