Search in sources :

Example 31 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project android_frameworks_base by AOSPA.

the class LinkifyTest method testNormal.

@SmallTest
public void testNormal() throws Exception {
    TextView tv;
    tv = new TextView(getContext());
    tv.setAutoLinkMask(Linkify.ALL);
    tv.setText("Hey, foo@google.com, call 415-555-1212.");
    assertTrue(tv.getMovementMethod() instanceof LinkMovementMethod);
    assertTrue(tv.getUrls().length == 2);
}
Also used : LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 32 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project android_frameworks_base by ResurrectionRemix.

the class LinkifyTest method testNormal.

@SmallTest
public void testNormal() throws Exception {
    TextView tv;
    tv = new TextView(getContext());
    tv.setAutoLinkMask(Linkify.ALL);
    tv.setText("Hey, foo@google.com, call 415-555-1212.");
    assertTrue(tv.getMovementMethod() instanceof LinkMovementMethod);
    assertTrue(tv.getUrls().length == 2);
}
Also used : LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 33 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project android_frameworks_base by ResurrectionRemix.

the class QSFooter method createDialog.

private void createDialog() {
    final String deviceOwnerPackage = mSecurityController.getDeviceOwnerName();
    final String profileOwnerPackage = mSecurityController.getProfileOwnerName();
    final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled();
    final String primaryVpn = mSecurityController.getPrimaryVpnName();
    final String profileVpn = mSecurityController.getProfileVpnName();
    boolean hasProfileOwner = mSecurityController.hasProfileOwner();
    boolean isBranded = deviceOwnerPackage == null && mSecurityController.isVpnBranded();
    mDialog = new SystemUIDialog(mContext);
    if (!isBranded) {
        mDialog.setTitle(getTitle(deviceOwnerPackage));
    }
    CharSequence msg = getMessage(deviceOwnerPackage, profileOwnerPackage, primaryVpn, profileVpn, hasProfileOwner, isBranded);
    if (deviceOwnerPackage == null) {
        mDialog.setMessage(msg);
        if (mSecurityController.isVpnEnabled() && !mSecurityController.isVpnRestricted()) {
            mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
        }
    } else {
        View dialogView = LayoutInflater.from(mContext).inflate(R.layout.quick_settings_footer_dialog, null, false);
        mDialog.setView(dialogView);
        TextView deviceOwnerWarning = (TextView) dialogView.findViewById(R.id.device_owner_warning);
        deviceOwnerWarning.setText(msg);
        // Make the link "learn more" clickable.
        deviceOwnerWarning.setMovementMethod(new LinkMovementMethod());
        if (primaryVpn == null) {
            dialogView.findViewById(R.id.vpn_icon).setVisibility(View.GONE);
            dialogView.findViewById(R.id.vpn_subtitle).setVisibility(View.GONE);
            dialogView.findViewById(R.id.vpn_warning).setVisibility(View.GONE);
        } else {
            final SpannableStringBuilder message = new SpannableStringBuilder();
            message.append(mContext.getString(R.string.monitoring_description_do_body_vpn, primaryVpn));
            if (!mSecurityController.isVpnRestricted()) {
                message.append(mContext.getString(R.string.monitoring_description_vpn_settings_separator));
                message.append(mContext.getString(R.string.monitoring_description_vpn_settings), new VpnSpan(), 0);
            }
            TextView vpnWarning = (TextView) dialogView.findViewById(R.id.vpn_warning);
            vpnWarning.setText(message);
            // Make the link "Open VPN Settings" clickable.
            vpnWarning.setMovementMethod(new LinkMovementMethod());
        }
        if (!isNetworkLoggingEnabled) {
            dialogView.findViewById(R.id.network_logging_icon).setVisibility(View.GONE);
            dialogView.findViewById(R.id.network_logging_subtitle).setVisibility(View.GONE);
            dialogView.findViewById(R.id.network_logging_warning).setVisibility(View.GONE);
        }
    }
    mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getPositiveButton(isBranded), this);
    mDialog.show();
    mDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 34 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project android_frameworks_base by DirtyUnicorns.

the class QSFooter method createDialog.

private void createDialog() {
    final String deviceOwnerPackage = mSecurityController.getDeviceOwnerName();
    final String profileOwnerPackage = mSecurityController.getProfileOwnerName();
    final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled();
    final String primaryVpn = mSecurityController.getPrimaryVpnName();
    final String profileVpn = mSecurityController.getProfileVpnName();
    boolean hasProfileOwner = mSecurityController.hasProfileOwner();
    boolean isBranded = deviceOwnerPackage == null && mSecurityController.isVpnBranded();
    mDialog = new SystemUIDialog(mContext);
    if (!isBranded) {
        mDialog.setTitle(getTitle(deviceOwnerPackage));
    }
    CharSequence msg = getMessage(deviceOwnerPackage, profileOwnerPackage, primaryVpn, profileVpn, hasProfileOwner, isBranded);
    if (deviceOwnerPackage == null) {
        mDialog.setMessage(msg);
        if (mSecurityController.isVpnEnabled() && !mSecurityController.isVpnRestricted()) {
            mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
        }
    } else {
        View dialogView = LayoutInflater.from(mContext).inflate(R.layout.quick_settings_footer_dialog, null, false);
        mDialog.setView(dialogView);
        TextView deviceOwnerWarning = (TextView) dialogView.findViewById(R.id.device_owner_warning);
        deviceOwnerWarning.setText(msg);
        // Make the link "learn more" clickable.
        deviceOwnerWarning.setMovementMethod(new LinkMovementMethod());
        if (primaryVpn == null) {
            dialogView.findViewById(R.id.vpn_icon).setVisibility(View.GONE);
            dialogView.findViewById(R.id.vpn_subtitle).setVisibility(View.GONE);
            dialogView.findViewById(R.id.vpn_warning).setVisibility(View.GONE);
        } else {
            final SpannableStringBuilder message = new SpannableStringBuilder();
            message.append(mContext.getString(R.string.monitoring_description_do_body_vpn, primaryVpn));
            if (!mSecurityController.isVpnRestricted()) {
                message.append(mContext.getString(R.string.monitoring_description_vpn_settings_separator));
                message.append(mContext.getString(R.string.monitoring_description_vpn_settings), new VpnSpan(), 0);
            }
            TextView vpnWarning = (TextView) dialogView.findViewById(R.id.vpn_warning);
            vpnWarning.setText(message);
            // Make the link "Open VPN Settings" clickable.
            vpnWarning.setMovementMethod(new LinkMovementMethod());
        }
        if (!isNetworkLoggingEnabled) {
            dialogView.findViewById(R.id.network_logging_icon).setVisibility(View.GONE);
            dialogView.findViewById(R.id.network_logging_subtitle).setVisibility(View.GONE);
            dialogView.findViewById(R.id.network_logging_warning).setVisibility(View.GONE);
        }
    }
    mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getPositiveButton(isBranded), this);
    mDialog.show();
    mDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 35 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project android_frameworks_base by crdroidandroid.

the class LinkifyTest method testUnclickable.

@SmallTest
public void testUnclickable() throws Exception {
    TextView tv;
    tv = new TextView(getContext());
    tv.setAutoLinkMask(Linkify.ALL);
    tv.setLinksClickable(false);
    tv.setText("Hey, foo@google.com, call 415-555-1212.");
    assertFalse(tv.getMovementMethod() instanceof LinkMovementMethod);
    assertTrue(tv.getUrls().length == 2);
}
Also used : LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

LinkMovementMethod (android.text.method.LinkMovementMethod)50 TextView (android.widget.TextView)40 SmallTest (android.test.suitebuilder.annotation.SmallTest)18 View (android.view.View)12 Spannable (android.text.Spannable)8 TextAppearanceSpan (android.text.style.TextAppearanceSpan)7 ImageView (android.widget.ImageView)7 SpannableStringBuilder (android.text.SpannableStringBuilder)6 SpannableString (android.text.SpannableString)4 ActivityNotFoundException (android.content.ActivityNotFoundException)3 Context (android.content.Context)3 ViewGroup (android.view.ViewGroup)3 SystemUIDialog (com.android.systemui.statusbar.phone.SystemUIDialog)3 Intent (android.content.Intent)2 PackageManager (android.content.pm.PackageManager)2 Resources (android.content.res.Resources)2 Paint (android.graphics.Paint)2 Bundle (android.os.Bundle)2 ActionBar (android.support.v7.app.ActionBar)2 AlertDialog (android.support.v7.app.AlertDialog)2