Search in sources :

Example 1 with PageTitle

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

the class BottomContentView method onTalkClick.

@OnClick(R.id.page_talk_container)
void onTalkClick(View v) {
    PageTitle title = page.getTitle();
    PageTitle talkPageTitle = new PageTitle("Talk", title.getPrefixedText(), title.getWikiSite());
    visitInExternalBrowser(parentFragment.getContext(), Uri.parse(talkPageTitle.getMobileUri()));
}
Also used : PageTitle(org.wikipedia.page.PageTitle) OnClick(butterknife.OnClick)

Example 2 with PageTitle

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

the class BottomContentView method setup.

public void setup(PageFragment parentFragment, CommunicationBridge bridge, ObservableWebView webview) {
    this.parentFragment = parentFragment;
    this.webView = webview;
    this.bridge = bridge;
    setWebView(webview);
    webview.addOnScrollChangeListener(this);
    webview.addOnContentHeightChangedListener(this);
    pageExternalLink.setPaintFlags(pageExternalLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    if (parentFragment.callback() != null) {
        ListViewContextMenuListener contextMenuListener = new LongPressHandler(parentFragment);
        new org.wikipedia.LongPressHandler(readMoreList, HistoryEntry.SOURCE_INTERNAL_LINK, contextMenuListener);
    }
    addOnLayoutChangeListener((View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) -> {
        if (prevLayoutHeight == getHeight()) {
            return;
        }
        prevLayoutHeight = getHeight();
        padWebView();
    });
    readMoreList.setAdapter(readMoreAdapter);
    readMoreList.setOnItemClickListener((AdapterView<?> parent, View view, int position, long id) -> {
        PageTitle title = readMoreAdapter.getItem(position).getPageTitle();
        HistoryEntry historyEntry = new HistoryEntry(title, HistoryEntry.SOURCE_INTERNAL_LINK);
        parentFragment.loadPage(title, historyEntry);
        funnel.logSuggestionClicked(page.getTitle(), readMoreItems.getResults(), position);
    });
    // hide ourselves by default
    hide();
}
Also used : PageContainerLongPressHandler(org.wikipedia.page.PageContainerLongPressHandler) ListViewContextMenuListener(org.wikipedia.LongPressHandler.ListViewContextMenuListener) PageTitle(org.wikipedia.page.PageTitle) HistoryEntry(org.wikipedia.history.HistoryEntry) AdapterView(android.widget.AdapterView) ConfigurableTextView(org.wikipedia.views.ConfigurableTextView) LinearLayoutOverWebView(org.wikipedia.views.LinearLayoutOverWebView) BindView(butterknife.BindView) GoneIfEmptyTextView(org.wikipedia.views.GoneIfEmptyTextView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) ListView(android.widget.ListView) ObservableWebView(org.wikipedia.views.ObservableWebView)

Example 3 with PageTitle

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

the class ShareHandler method showWiktionaryDefinition.

public void showWiktionaryDefinition(String text) {
    PageTitle title = fragment.getTitle();
    fragment.showBottomSheet(WiktionaryDialog.newInstance(title, text));
}
Also used : PageTitle(org.wikipedia.page.PageTitle)

Example 4 with PageTitle

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

the class ShareHandler method shareSnippet.

private void shareSnippet(@NonNull CharSequence input) {
    final String selectedText = StringUtil.sanitizeText(input.toString());
    final PageTitle title = fragment.getTitle();
    final String leadImageNameText = fragment.getPage().getPageProperties().getLeadImageName() != null ? fragment.getPage().getPageProperties().getLeadImageName() : "";
    new ImageLicenseFetchClient().request(title.getWikiSite(), new PageTitle(Namespace.FILE.toLegacyString(), leadImageNameText, title.getWikiSite()), new ImageLicenseFetchClient.Callback() {

        @Override
        public void success(@NonNull Call<MwQueryResponse> call, @NonNull ImageLicense result) {
            final Bitmap snippetBitmap = SnippetImage.getSnippetImage(fragment.getContext(), fragment.getLeadImageBitmap(), title.getDisplayText(), fragment.getPage().isMainPage() ? "" : StringUtils.capitalize(title.getDescription()), selectedText, result);
            fragment.showBottomSheet(new PreviewDialog(fragment.getContext(), snippetBitmap, title, selectedText, funnel));
        }

        @Override
        public void failure(@NonNull Call<MwQueryResponse> call, @NonNull Throwable caught) {
            // If we failed to get license info for the lead image, just share the text
            PreviewDialog.shareAsText(fragment.getContext(), title, selectedText, funnel);
            L.e("Error fetching image license info for " + title.getDisplayText(), caught);
        }
    });
}
Also used : ImageLicense(org.wikipedia.gallery.ImageLicense) Bitmap(android.graphics.Bitmap) ImageLicenseFetchClient(org.wikipedia.gallery.ImageLicenseFetchClient) PageTitle(org.wikipedia.page.PageTitle) MwQueryResponse(org.wikipedia.dataclient.mwapi.MwQueryResponse)

Example 5 with PageTitle

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

the class RandomFragment method onSaveShareClick.

@OnClick(R.id.random_save_button)
void onSaveShareClick() {
    PageTitle title = getTopTitle();
    if (title == null) {
        return;
    }
    if (saveButtonState) {
        new ReadingListBookmarkMenu(saveButton, new ReadingListBookmarkMenu.Callback() {

            @Override
            public void onAddRequest(@Nullable ReadingListPage page) {
                onAddPageToList(title);
            }

            @Override
            public void onDeleted(@Nullable ReadingListPage page) {
                FeedbackUtil.showMessage(getActivity(), getString(R.string.reading_list_item_deleted, title.getDisplayText()));
                updateSaveShareButton(title);
            }
        }).show(title);
    } else {
        onAddPageToList(title);
    }
}
Also used : ReadingListBookmarkMenu(org.wikipedia.readinglist.ReadingListBookmarkMenu) PageTitle(org.wikipedia.page.PageTitle) ReadingListPage(org.wikipedia.readinglist.database.ReadingListPage) Nullable(android.support.annotation.Nullable) 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