Search in sources :

Example 1 with LinkMovementMethodExt

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

the class ReadingListSyncBehaviorDialogs method promptLogInToSyncDialog.

static void promptLogInToSyncDialog(@NonNull Activity activity) {
    if (!Prefs.shouldShowReadingListSyncEnablePrompt()) {
        return;
    }
    View view = activity.getLayoutInflater().inflate(R.layout.dialog_with_checkbox, null);
    TextView message = view.findViewById(R.id.dialog_message);
    CheckBox checkbox = view.findViewById(R.id.dialog_checkbox);
    message.setText(StringUtil.fromHtml(activity.getString(R.string.reading_lists_login_reminder_text_with_link)));
    message.setMovementMethod(new LinkMovementMethodExt((@NonNull String url, @Nullable String notUsed) -> {
        FeedbackUtil.showAndroidAppFAQ(activity);
    }));
    new AlertDialog.Builder(activity).setCancelable(false).setTitle(R.string.reading_list_login_reminder_title).setView(view).setPositiveButton(R.string.reading_list_preference_login_or_signup_to_enable_sync_dialog_login, (dialogInterface, i) -> {
        Intent loginIntent = LoginActivity.newIntent(activity, LoginFunnel.SOURCE_READING_MANUAL_SYNC);
        activity.startActivity(loginIntent);
    }).setNegativeButton(R.string.reading_list_prompt_turned_sync_on_dialog_no_thanks, null).setOnDismissListener((dialog) -> {
        Prefs.shouldShowReadingListSyncEnablePrompt(!checkbox.isChecked());
    }).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) LoginFunnel(org.wikipedia.analytics.LoginFunnel) SavedPageSyncService(org.wikipedia.savedpages.SavedPageSyncService) R(org.wikipedia.R) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) Prefs(org.wikipedia.settings.Prefs) SettingsActivity(org.wikipedia.settings.SettingsActivity) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) CheckBox(android.widget.CheckBox) ReadingListDbHelper(org.wikipedia.readinglist.database.ReadingListDbHelper) StringUtil(org.wikipedia.util.StringUtil) View(android.view.View) LoginActivity(org.wikipedia.login.LoginActivity) Nullable(android.support.annotation.Nullable) ReadingListSyncAdapter(org.wikipedia.readinglist.sync.ReadingListSyncAdapter) Activity(android.app.Activity) LinkMovementMethodExt(org.wikipedia.page.LinkMovementMethodExt) FeedbackUtil(org.wikipedia.util.FeedbackUtil) CheckBox(android.widget.CheckBox) LinkMovementMethodExt(org.wikipedia.page.LinkMovementMethodExt) TextView(android.widget.TextView) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View)

Example 2 with LinkMovementMethodExt

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

the class LocalCompilationsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_local_compilations, container, false);
    unbinder = ButterKnife.bind(this, view);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DrawableItemDecoration(getContext(), R.attr.list_separator_drawable));
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    errorView.setBackClickListener(v -> getActivity().finish());
    emptyDescription.setMovementMethod(LinkMovementMethod.getInstance());
    emptyDescription.setText(StringUtil.fromHtml(getString(R.string.offline_library_empty_description_sideload)));
    RichTextUtil.removeUnderlinesFromLinks(emptyDescription);
    packsHint.setMovementMethod(LinkMovementMethod.getInstance());
    packsHint.setText(StringUtil.fromHtml(getString(R.string.offline_library_packs_hint)));
    RichTextUtil.removeUnderlinesFromLinks(packsHint);
    dataUsageHint.setMovementMethod(new LinkMovementMethodExt((url, titleString) -> {
        if (url.equals(UriUtil.LOCAL_URL_SETTINGS)) {
            startActivity(SettingsActivity.newIntent(getContext()));
        }
    }));
    dataUsageHint.setText(StringUtil.fromHtml(getString(R.string.offline_library_data_usage_hint)));
    RichTextUtil.removeUnderlinesFromLinks(dataUsageHint);
    funnel = new OfflineLibraryFunnel(WikipediaApp.getInstance(), 0);
    return view;
}
Also used : ShareCompat(android.support.v4.app.ShareCompat) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) ButterKnife(butterknife.ButterKnife) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) LinkMovementMethod(android.text.method.LinkMovementMethod) DefaultViewHolder(org.wikipedia.views.DefaultViewHolder) ShareUtil(org.wikipedia.util.ShareUtil) PageItemView(org.wikipedia.views.PageItemView) OnClick(butterknife.OnClick) SettingsActivity(org.wikipedia.settings.SettingsActivity) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) FileUtil.bytesToUserVisibleUnit(org.wikipedia.util.FileUtil.bytesToUserVisibleUnit) WikipediaApp(org.wikipedia.WikipediaApp) FragmentUtil(org.wikipedia.activity.FragmentUtil) StringUtil(org.wikipedia.util.StringUtil) View(android.view.View) SearchEmptyView(org.wikipedia.views.SearchEmptyView) Unbinder(butterknife.Unbinder) LinkMovementMethodExt(org.wikipedia.page.LinkMovementMethodExt) R(org.wikipedia.R) RichTextUtil(org.wikipedia.richtext.RichTextUtil) LayoutInflater(android.view.LayoutInflater) OfflineLibraryFunnel(org.wikipedia.analytics.OfflineLibraryFunnel) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) PopupMenu(android.support.v7.widget.PopupMenu) UriUtil(org.wikipedia.util.UriUtil) ViewGroup(android.view.ViewGroup) File(java.io.File) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) TextView(android.widget.TextView) WikiErrorView(org.wikipedia.views.WikiErrorView) ResourceUtil(org.wikipedia.util.ResourceUtil) Nullable(android.support.annotation.Nullable) DimenUtil(org.wikipedia.util.DimenUtil) DateUtil.getShortDateString(org.wikipedia.util.DateUtil.getShortDateString) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) DrawableItemDecoration(org.wikipedia.views.DrawableItemDecoration) OfflineLibraryFunnel(org.wikipedia.analytics.OfflineLibraryFunnel) LinkMovementMethodExt(org.wikipedia.page.LinkMovementMethodExt) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) PageItemView(org.wikipedia.views.PageItemView) BindView(butterknife.BindView) View(android.view.View) SearchEmptyView(org.wikipedia.views.SearchEmptyView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) WikiErrorView(org.wikipedia.views.WikiErrorView) Nullable(android.support.annotation.Nullable)

Example 3 with LinkMovementMethodExt

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

the class OnboardingPageView method init.

private void init(@Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    setOrientation(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? VERTICAL : HORIZONTAL);
    inflate(getContext(), R.layout.view_onboarding_page, this);
    ButterKnife.bind(this);
    if (attrs != null) {
        TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.OnboardingPageView, defStyleAttr, defStyleRes);
        Drawable centeredImage = ContextCompat.getDrawable(getContext(), array.getResourceId(R.styleable.OnboardingPageView_centeredImage, -1));
        String primaryText = array.getString(R.styleable.OnboardingPageView_primaryText);
        String secondaryText = array.getString(R.styleable.OnboardingPageView_secondaryText);
        String tertiaryText = array.getString(R.styleable.OnboardingPageView_tertiaryText);
        String switchText = array.getString(R.styleable.OnboardingPageView_switchText);
        int imageSize = array.getDimensionPixelSize(R.styleable.OnboardingPageView_imageSize, 0);
        Drawable background = array.getDrawable(R.styleable.OnboardingPageView_background);
        if (background != null) {
            setBackground(background);
        }
        FrameLayout.LayoutParams imageParams = (FrameLayout.LayoutParams) imageViewCentered.getLayoutParams();
        imageParams.width = imageSize;
        imageParams.height = imageSize;
        imageViewCentered.setLayoutParams(imageParams);
        imageViewCentered.setImageDrawable(centeredImage);
        primaryTextView.setText(primaryText);
        secondaryTextView.setText(StringUtil.fromHtml(secondaryText));
        tertiaryTextView.setText(tertiaryText);
        switchContainer.setVisibility(TextUtils.isEmpty(switchText) ? GONE : VISIBLE);
        switchView.setText(switchText);
        secondaryTextView.setMovementMethod(new LinkMovementMethodExt((@NonNull String url, @Nullable String notUsed) -> {
            if (callback != null) {
                callback.onLinkClick(OnboardingPageView.this, url);
            }
        }));
        array.recycle();
    }
}
Also used : LinkMovementMethodExt(org.wikipedia.page.LinkMovementMethodExt) TypedArray(android.content.res.TypedArray) FrameLayout(android.widget.FrameLayout) Drawable(android.graphics.drawable.Drawable)

Example 4 with LinkMovementMethodExt

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

the class EditSectionActivity method updateEditLicenseText.

private void updateEditLicenseText() {
    TextView editLicenseText = findViewById(R.id.edit_section_license_text);
    editLicenseText.setText(StringUtil.fromHtml(String.format(getString(AccountUtil.isLoggedIn() ? R.string.edit_save_action_license_logged_in : R.string.edit_save_action_license_anon), getString(R.string.terms_of_use_url), getString(R.string.cc_by_sa_3_url))));
    editLicenseText.setMovementMethod(new LinkMovementMethodExt((@NonNull String url, @Nullable String notUsed) -> {
        if (url.equals("https://#login")) {
            funnel.logLoginAttempt();
            Intent loginIntent = LoginActivity.newIntent(EditSectionActivity.this, LoginFunnel.SOURCE_EDIT, funnel.getSessionToken());
            startActivityForResult(loginIntent, Constants.ACTIVITY_REQUEST_LOGIN);
        } else {
            handleExternalLink(EditSectionActivity.this, Uri.parse(url));
        }
    }));
}
Also used : LinkMovementMethodExt(org.wikipedia.page.LinkMovementMethodExt) TextView(android.widget.TextView) Intent(android.content.Intent)

Example 5 with LinkMovementMethodExt

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

the class ReadingListSyncBehaviorDialogs method promptEnableSyncDialog.

public static void promptEnableSyncDialog(@NonNull Activity activity) {
    if (!Prefs.shouldShowReadingListSyncEnablePrompt()) {
        return;
    }
    View view = activity.getLayoutInflater().inflate(R.layout.dialog_with_checkbox, null);
    TextView message = view.findViewById(R.id.dialog_message);
    CheckBox checkbox = view.findViewById(R.id.dialog_checkbox);
    message.setText(StringUtil.fromHtml(activity.getString(R.string.reading_list_prompt_turned_sync_on_dialog_text)));
    message.setMovementMethod(new LinkMovementMethodExt((@NonNull String url, @Nullable String notUsed) -> {
        FeedbackUtil.showAndroidAppFAQ(activity);
    }));
    new AlertDialog.Builder(activity).setCancelable(false).setTitle(R.string.reading_list_prompt_turned_sync_on_dialog_title).setView(view).setPositiveButton(R.string.reading_list_prompt_turned_sync_on_dialog_enable_syncing, (dialogInterface, i) -> {
        Prefs.shouldShowReadingListSyncMergePrompt(true);
        ReadingListSyncAdapter.setSyncEnabledWithSetup();
    }).setNegativeButton(R.string.reading_list_prompt_turned_sync_on_dialog_no_thanks, null).setOnDismissListener((dialog) -> {
        Prefs.shouldShowReadingListSyncEnablePrompt(!checkbox.isChecked());
    }).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) LoginFunnel(org.wikipedia.analytics.LoginFunnel) SavedPageSyncService(org.wikipedia.savedpages.SavedPageSyncService) R(org.wikipedia.R) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) Prefs(org.wikipedia.settings.Prefs) SettingsActivity(org.wikipedia.settings.SettingsActivity) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) CheckBox(android.widget.CheckBox) ReadingListDbHelper(org.wikipedia.readinglist.database.ReadingListDbHelper) StringUtil(org.wikipedia.util.StringUtil) View(android.view.View) LoginActivity(org.wikipedia.login.LoginActivity) Nullable(android.support.annotation.Nullable) ReadingListSyncAdapter(org.wikipedia.readinglist.sync.ReadingListSyncAdapter) Activity(android.app.Activity) LinkMovementMethodExt(org.wikipedia.page.LinkMovementMethodExt) FeedbackUtil(org.wikipedia.util.FeedbackUtil) CheckBox(android.widget.CheckBox) LinkMovementMethodExt(org.wikipedia.page.LinkMovementMethodExt) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

LinkMovementMethodExt (org.wikipedia.page.LinkMovementMethodExt)5 Intent (android.content.Intent)4 TextView (android.widget.TextView)4 NonNull (android.support.annotation.NonNull)3 Nullable (android.support.annotation.Nullable)3 View (android.view.View)3 R (org.wikipedia.R)3 SettingsActivity (org.wikipedia.settings.SettingsActivity)3 StringUtil (org.wikipedia.util.StringUtil)3 Activity (android.app.Activity)2 AlertDialog (android.support.v7.app.AlertDialog)2 CheckBox (android.widget.CheckBox)2 LoginFunnel (org.wikipedia.analytics.LoginFunnel)2 LoginActivity (org.wikipedia.login.LoginActivity)2 ReadingListDbHelper (org.wikipedia.readinglist.database.ReadingListDbHelper)2 ReadingListSyncAdapter (org.wikipedia.readinglist.sync.ReadingListSyncAdapter)2 TypedArray (android.content.res.TypedArray)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 ShareCompat (android.support.v4.app.ShareCompat)1