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);
}
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));
}
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));
}
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));
}
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);
}
}
}
Aggregations