Example usage for android.text.style ClickableSpan ClickableSpan

List of usage examples for android.text.style ClickableSpan ClickableSpan

Introduction

In this page you can find the example usage for android.text.style ClickableSpan ClickableSpan.

Prototype

ClickableSpan

Source Link

Usage

From source file:com.itbooks.app.fragments.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Get app version
    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String versionName;/*from  w w  w. j  a  va  2s  .c  o m*/
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }

    // About.
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(Html.fromHtml(getString(R.string.about_body, versionName)));

    // Licenses.
    SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
    licensesLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showOpenSourceLicenses(getActivity());
        }
    }, 0, licensesLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(licensesLink);

    // End User License Agreement.
    SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
    eulaLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showEula(getActivity());
        }
    }, 0, eulaLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(eulaLink);

    // Show "About" dialog.
    LayoutInflater layoutInflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null);
    aboutBodyView.setText(aboutBody);
    aboutBodyView.setMovementMethod(new LinkMovementMethod());

    return new AlertDialog.Builder(getActivity()).setTitle(R.string.lbl_about).setView(aboutBodyView)
            .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.osc.tweet.app.fragments.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Get app version
    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String versionName;//from  ww  w . j  a  v a2 s . c  om
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }

    // About.
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(
            Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName)));

    // Licenses.
    SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
    licensesLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showOpenSourceLicenses(getActivity());
        }
    }, 0, licensesLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(licensesLink);

    // End User License Agreement.
    SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
    eulaLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showEula(getActivity());
        }
    }, 0, eulaLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(eulaLink);

    // Show "About" dialog.
    LayoutInflater layoutInflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null);
    aboutBodyView.setText(aboutBody);
    aboutBodyView.setMovementMethod(new LinkMovementMethod());

    return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(aboutBodyView)
            .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.topfeeds4j.sample.app.fragments.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Get app version
    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String versionName;/*  ww w . j a v  a 2  s  . com*/
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }

    // About.
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(
            Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName)));

    // Licenses.
    SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
    licensesLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showOpenSourceLicenses(getActivity());
        }
    }, 0, licensesLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(licensesLink);

    // End User License Agreement.
    SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
    eulaLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showEula(getActivity());
        }
    }, 0, eulaLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(eulaLink);

    // Show "About" dialog.
    LayoutInflater layoutInflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null);
    aboutBodyView.setText(aboutBody);
    aboutBodyView.setLinkTextColor(getResources().getColor(R.color.com_facebook_blue));
    aboutBodyView.setMovementMethod(new LinkMovementMethod());

    return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(aboutBodyView)
            .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.marstemp.app.fragments.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Get app version
    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String versionName;// w  w  w  .  j  ava2s  .c  om
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }

    // About.
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(
            Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName)));

    // Licenses.
    SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
    licensesLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showOpenSourceLicenses(getActivity());
        }
    }, 0, licensesLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(licensesLink);

    // End User License Agreement.
    SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
    eulaLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showEula(getActivity());
        }
    }, 0, eulaLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(eulaLink);

    // Show "About" dialog.
    LayoutInflater layoutInflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogV = layoutInflater.inflate(R.layout.fragment_dialog_about, null);
    ;
    TextView aboutBodyView = (TextView) dialogV.findViewById(R.id.dialog_text_tv);
    aboutBodyView.setText(aboutBody);
    aboutBodyView.setMovementMethod(new LinkMovementMethod());
    dialogV.findViewById(R.id.powered_by_ll).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            WebViewActivity.showInstance(getActivity(), getString(R.string.lbl_maas),
                    Prefs.getInstance().getApiHome());
        }
    });
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(dialogV)
            .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:widget.map.com.urlocationmapwidget.app.fragments.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Get app version
    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String versionName;/*from   w ww. j  a  v  a 2  s .c om*/
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }

    // About.
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(
            Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName)));

    // Licenses.
    SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
    licensesLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showOpenSourceLicenses(getActivity());
        }
    }, 0, licensesLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(licensesLink);

    // End User License Agreement.
    SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
    eulaLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showEula(getActivity());
        }
    }, 0, eulaLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(eulaLink);

    // Show "About" dialog.
    LayoutInflater layoutInflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.dialog_fragment_about, null);
    aboutBodyView.setText(aboutBody);
    aboutBodyView.setMovementMethod(new LinkMovementMethod());

    return new AlertDialog.Builder(getActivity()).setTitle(R.string.menu_about).setView(aboutBodyView)
            .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.schautup.fragments.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Get app version
    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String versionName;//  w ww .  j a  va 2 s  . co  m
    String appName = getString(R.string.application_name);
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }

    // About.
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(Html.fromHtml(getString(R.string.about_body, appName, versionName)));

    // Licenses.
    SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
    licensesLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showOpenSourceLicenses(getActivity());
        }
    }, 0, licensesLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(licensesLink);

    // End User License Agreement.
    SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
    eulaLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showEula(getActivity());
        }
    }, 0, eulaLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(eulaLink);

    // Show "About" dialog.
    LayoutInflater layoutInflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.dialog_about, null);
    aboutBodyView.setText(aboutBody);
    aboutBodyView.setMovementMethod(new LinkMovementMethod());

    return new AlertDialog.Builder(getActivity()).setTitle(R.string.lbl_about).setView(aboutBodyView)
            .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.playground.notification.app.fragments.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Get app version
    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String versionName;// w w w  .  j a  va2  s. co m
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }

    // About.
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(
            Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName)));

    // Licenses.
    SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
    licensesLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showOpenSourceLicenses(getActivity());
        }
    }, 0, licensesLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(licensesLink);

    // End User License Agreement.
    SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
    eulaLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showEula(getActivity());
        }
    }, 0, eulaLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(eulaLink);

    // Show "About" dialog.
    LayoutInflater layoutInflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogV = layoutInflater.inflate(R.layout.fragment_dialog_about, null);
    ;
    TextView aboutBodyView = (TextView) dialogV.findViewById(R.id.dialog_text_tv);
    aboutBodyView.setText(aboutBody);
    aboutBodyView.setMovementMethod(new LinkMovementMethod());

    dialogV.findViewById(R.id.powered_by_ll).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Utils.openExternalBrowser(getActivity(), "http://" + getString(R.string.support_spielplatz_radar));
        }
    });

    dialogV.findViewById(R.id.weather_by_ll).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Utils.openExternalBrowser(getActivity(), "http://" + getString(R.string.support_openweathermap));
        }
    });

    return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(dialogV)
            .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.liferay.mobile.screens.viewsets.westeros.auth.signup.SignUpView.java

private void initClickableTermsAndConditions() {
    TextView textView = (TextView) findViewById(R.id.terms);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    SpannableStringBuilder ssb = new SpannableStringBuilder("I accept the terms and conditions");

    ssb.setSpan(new ClickableSpan() {
        @Override//from  w ww  .j  a v  a 2 s  .c o m
        public void onClick(View widget) {
            SignUpScreenlet signUpScreenlet = getSignUpScreenlet();
            signUpScreenlet.performUserAction(SignUpScreenlet.TERMS_AND_CONDITIONS);
        }
    }, 13, ssb.length(), 0);

    ssb.setSpan(new StyleSpan(Typeface.BOLD), 13, ssb.length(), 0);
    ssb.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), android.R.color.white)), 13,
            ssb.length(), 0);

    textView.setText(ssb, TextView.BufferType.SPANNABLE);
}

From source file:org.floens.chan.ui.controller.ThemeSettingsController.java

@Override
public void onCreate() {
    super.onCreate();

    navigationItem.setTitle(R.string.settings_screen_theme);
    navigationItem.swipeable = false;/*from   w w w  .j a v a  2 s .c o m*/
    view = inflateRes(R.layout.controller_theme);

    themeHelper = ThemeHelper.getInstance();
    themes = themeHelper.getThemes();

    pager = (ViewPager) view.findViewById(R.id.pager);
    done = (FloatingActionButton) view.findViewById(R.id.add);
    done.setOnClickListener(this);

    textView = (TextView) view.findViewById(R.id.text);

    SpannableString changeAccentColor = new SpannableString(getString(R.string.setting_theme_accent));
    changeAccentColor.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View widget) {
            showAccentColorPicker();
        }
    }, 0, changeAccentColor.length(), 0);

    textView.setText(TextUtils.concat(getString(R.string.setting_theme_explanation), changeAccentColor));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    adapter = new Adapter();
    pager.setAdapter(adapter);

    ChanSettings.ThemeColor currentSettingsTheme = ChanSettings.getThemeAndColor();
    for (int i = 0; i < themeHelper.getThemes().size(); i++) {
        Theme theme = themeHelper.getThemes().get(i);
        ThemeHelper.PrimaryColor primaryColor = theme.primaryColor;

        if (theme.name.equals(currentSettingsTheme.theme)) {
            // Current theme
            pager.setCurrentItem(i, false);
        }
        selectedPrimaryColors.add(primaryColor);
    }
    selectedAccentColor = themeHelper.getTheme().accentColor;
    done.setBackgroundTintList(ColorStateList.valueOf(selectedAccentColor.color));
}

From source file:com.github.guwenk.smuradio.SignInDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    builder = new AlertDialog.Builder(getActivity());
    View signInDialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_sign_in, null);
    builder.setView(signInDialogView);//from  w w w . ja  v  a 2 s  .c  o m
    builder.setMessage(R.string.upload_your_song);

    checkBox = (CheckBox) signInDialogView.findViewById(R.id.checkBox2);

    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }

    check1 = false;
    check2 = false;
    check3 = false;
    // Log.d(AuthTag, "onCreateDialog " + check1 + " " + check2 + " " + check3);

    this.mGoogleApiClient = OrderActivity.getmGoogleApiClient();
    mAuth = FirebaseAuth.getInstance();

    selectFileButton = (Button) signInDialogView.findViewById(R.id.selectFileButton);
    selectFileButton.setOnClickListener(new customButtonClickListener());

    signInButton = (SignInButton) signInDialogView.findViewById(R.id.sign_in_button);
    signInButton.setStyle(SignInButton.SIZE_WIDE, SignInButton.COLOR_AUTO);
    signInButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            signIn();
        }
    });

    builder.setPositiveButton(getString(R.string.next), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO upload song
        }
    });

    builder.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });

    SpannableString ss = new SpannableString(getString(R.string.you_accepting_license_agreement));
    ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(View textView) {
            Log.d(AuthTag, "click");
            LicenseDialog licenseDialog = new LicenseDialog();
            licenseDialog.show(getFragmentManager(), "Sing in dialog");
        }

        @Override
        public void updateDrawState(TextPaint ds) {
            super.updateDrawState(ds);
            ds.setUnderlineText(true);
        }
    };
    ss.setSpan(clickableSpan, 14, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    TextView textView = (TextView) signInDialogView.findViewById(R.id.textView);
    textView.setText(ss);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setHighlightColor(Color.TRANSPARENT);

    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            check2 = isChecked;
            Log.d(AuthTag, "Checked: " + isChecked);
            buttonStatus();
        }
    });

    mStorageRef = FirebaseStorage.getInstance().getReference();

    alert = builder.create();
    return alert;
}