Example usage for android.text.method LinkMovementMethod getInstance

List of usage examples for android.text.method LinkMovementMethod getInstance

Introduction

In this page you can find the example usage for android.text.method LinkMovementMethod getInstance.

Prototype

public static MovementMethod getInstance() 

Source Link

Usage

From source file:net.zjy.zxcardumper.Activities.MainMenu.java

/**
 * Check for NFC hardware, MIFARE Classic support and for external storage.
 * If the directory structure and the std. keys files is not already there
 * it will be created. Also, at the first run of this App, a warning
 * notice and a donate message will be displayed.
 * @see #copyStdKeysFilesIfNecessary()/*from  ww w  . j a  v  a 2s  .c  o  m*/
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_menu);

    // Show App version and footer.
    TextView tv = (TextView) findViewById(R.id.textViewMainFooter);
    tv.setText(getString(R.string.app_version) + ": " + Common.getVersionCode());

    // Add the context menu to the tools button.
    Button tools = (Button) findViewById(R.id.buttonMainTools);
    registerForContextMenu(tools);

    // Bind main layout buttons.
    mReadTag = (Button) findViewById(R.id.buttonMainReadTag);
    mWriteTag = (Button) findViewById(R.id.buttonMainWriteTag);
    mKeyEditor = (Button) findViewById(R.id.buttonMainEditKeyDump);
    mDumpEditor = (Button) findViewById(R.id.buttonMainEditCardDump);

    // Check if the user granted the app write permissions.
    if (Common.hasWritePermissionToExternalStorage(this)) {
        initFolders();
    } else {
        enableMenuButtons(false);
        // Request the permission.
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                REQUEST_WRITE_STORAGE_CODE);
    }

    // Check if there is an NFC hardware component.
    Common.setNfcAdapter(NfcAdapter.getDefaultAdapter(this));
    if (Common.getNfcAdapter() == null) {
        createNfcEnableDialog();
        mEnableNfc.show();
        mReadTag.setEnabled(false);
        mWriteTag.setEnabled(false);
        mResume = false;
    }

    // Show first usage notice.
    SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
    final Editor sharedEditor = sharedPref.edit();
    boolean isFirstRun = sharedPref.getBoolean("is_first_run", true);
    if (isFirstRun) {
        new AlertDialog.Builder(this).setTitle(R.string.dialog_first_run_title)
                .setIcon(android.R.drawable.ic_dialog_alert).setMessage(R.string.dialog_first_run)
                .setPositiveButton(R.string.action_ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        if (Common.IS_DONATE_VERSION) {
                            mResume = true;
                            checkNfc();
                        }
                        sharedEditor.putBoolean("is_first_run", false);
                        sharedEditor.apply();
                    }
                }).show();
        mResume = false;
    }

    if (Common.IS_DONATE_VERSION) {
        // Do not show the donate dialog.
        return;
    }
    // Show donate dialog.
    int currentVersion = 0;
    try {
        currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        Log.d(LOG_TAG, "Version not found.");
    }
    int lastVersion = sharedPref.getInt("mct_version", currentVersion - 1);
    boolean showDonateDialog = sharedPref.getBoolean("show_donate_dialog", true);
    if (lastVersion < currentVersion || showDonateDialog) {
        // This is either a new version of MCT or the user wants to see
        // the donate dialog.
        if (lastVersion < currentVersion) {
            // Update the version.
            sharedEditor.putInt("mct_version", currentVersion);
            sharedEditor.putBoolean("show_donate_dialog", true);
            sharedEditor.apply();
        }
        View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_donate,
                (ViewGroup) findViewById(android.R.id.content), false);
        final CheckBox showDonateDialogCheckBox = (CheckBox) dialogLayout
                .findViewById(R.id.checkBoxDonateDialog);
        new AlertDialog.Builder(this).setTitle(R.string.dialog_donate_title)
                .setIcon(android.R.drawable.ic_dialog_info).setView(dialogLayout)
                .setPositiveButton(R.string.action_beer_sounds_fine, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Open Google Play for the donate version of MCT.
                        Uri uri = Uri.parse("market://details?id=de." + "syss.MifareClassicToolDonate");
                        Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
                        try {
                            startActivity(goToMarket);
                        } catch (ActivityNotFoundException e) {
                            startActivity(
                                    new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store"
                                            + "/apps/details?id=de.syss.Mifare" + "ClassicToolDonate")));
                        }
                        if (showDonateDialogCheckBox.isChecked()) {
                            // Do not show the donate dialog again.
                            sharedEditor.putBoolean("show_donate_dialog", false);
                            sharedEditor.apply();
                        }
                        mResume = true;
                        checkNfc();
                    }
                }).setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        if (showDonateDialogCheckBox.isChecked()) {
                            // Do not show the donate dialog again.
                            sharedEditor.putBoolean("show_donate_dialog", false);
                            sharedEditor.apply();
                        }
                        mResume = true;
                        checkNfc();
                    }
                }).show();
        mResume = false;
    }

    // Check if there is MIFARE Classic support.
    if (!Common.useAsEditorOnly() && !Common.hasMifareClassicSupport()) {
        // Disable read/write tag options.
        mReadTag.setEnabled(false);
        mWriteTag.setEnabled(false);
        CharSequence styledText = Html.fromHtml(getString(R.string.dialog_no_mfc_support_device));
        AlertDialog ad = new AlertDialog.Builder(this).setTitle(R.string.dialog_no_mfc_support_device_title)
                .setMessage(styledText).setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(R.string.action_exit_app, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                }).setNegativeButton(R.string.action_continue, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        mResume = true;
                        checkNfc();
                    }
                }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        finish();
                    }
                }).show();
        // Make links clickable.
        ((TextView) ad.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
        mResume = false;
    }
}

From source file:de.syss.MifareClassicTool.Activities.MainMenu.java

/**
 * Check for NFC hardware, Mifare Classic support and for external storage.
 * If the directory structure and the std. keys files is not already there
 * it will be created. Also, at the first run of this App, a warning
 * notice and a donate message will be displayed.
 * @see #copyStdKeysFilesIfNecessary()//  ww  w  .ja  va2  s .co m
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_menu);

    // Show App version and footer.
    TextView tv = (TextView) findViewById(R.id.textViewMainFooter);
    tv.setText(getString(R.string.app_version) + ": " + Common.getVersionCode());

    // Add the context menu to the tools button.
    Button tools = (Button) findViewById(R.id.buttonMainTools);
    registerForContextMenu(tools);

    // Bind main layout buttons.
    mReadTag = (Button) findViewById(R.id.buttonMainReadTag);
    mWriteTag = (Button) findViewById(R.id.buttonMainWriteTag);
    mKeyEditor = (Button) findViewById(R.id.buttonMainEditKeyDump);
    mDumpEditor = (Button) findViewById(R.id.buttonMainEditCardDump);

    // Check if the user granted the app write permissions.
    if (Common.hasWritePermissionToExternalStorage(this)) {
        initFolders();
    } else {
        enableMenuButtons(false);
        // Request the permission.
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                REQUEST_WRITE_STORAGE_CODE);
    }

    // Check if there is an NFC hardware component.
    Common.setNfcAdapter(NfcAdapter.getDefaultAdapter(this));
    if (Common.getNfcAdapter() == null) {
        createNfcEnableDialog();
        mEnableNfc.show();
        mReadTag.setEnabled(false);
        mWriteTag.setEnabled(false);
        mResume = false;
    }

    // Show first usage notice.
    SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
    final Editor sharedEditor = sharedPref.edit();
    boolean isFirstRun = sharedPref.getBoolean("is_first_run", true);
    if (isFirstRun) {
        new AlertDialog.Builder(this).setTitle(R.string.dialog_first_run_title)
                .setIcon(android.R.drawable.ic_dialog_alert).setMessage(R.string.dialog_first_run)
                .setPositiveButton(R.string.action_ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        if (Common.IS_DONATE_VERSION) {
                            mResume = true;
                            checkNfc();
                        }
                        sharedEditor.putBoolean("is_first_run", false);
                        sharedEditor.apply();
                    }
                }).show();
        mResume = false;
    }

    if (Common.IS_DONATE_VERSION) {
        // Do not show the donate dialog.
        return;
    }
    // Show donate dialog.
    int currentVersion = 0;
    try {
        currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        Log.d(LOG_TAG, "Version not found.");
    }
    int lastVersion = sharedPref.getInt("mct_version", currentVersion - 1);
    boolean showDonateDialog = sharedPref.getBoolean("show_donate_dialog", true);
    if (lastVersion < currentVersion || showDonateDialog) {
        // This is either a new version of MCT or the user wants to see
        // the donate dialog.
        if (lastVersion < currentVersion) {
            // Update the version.
            sharedEditor.putInt("mct_version", currentVersion);
            sharedEditor.putBoolean("show_donate_dialog", true);
            sharedEditor.apply();
        }
        View dialogLayout = getLayoutInflater().inflate(R.layout.dialog_donate,
                (ViewGroup) findViewById(android.R.id.content), false);
        final CheckBox showDonateDialogCheckBox = (CheckBox) dialogLayout
                .findViewById(R.id.checkBoxDonateDialog);
        new AlertDialog.Builder(this).setTitle(R.string.dialog_donate_title)
                .setIcon(android.R.drawable.ic_dialog_info).setView(dialogLayout)
                .setPositiveButton(R.string.action_beer_sounds_fine, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Open Google Play for the donate version of MCT.
                        Uri uri = Uri.parse("market://details?id=de." + "syss.MifareClassicToolDonate");
                        Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
                        try {
                            startActivity(goToMarket);
                        } catch (ActivityNotFoundException e) {
                            startActivity(
                                    new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store"
                                            + "/apps/details?id=de.syss.Mifare" + "ClassicToolDonate")));
                        }
                        if (showDonateDialogCheckBox.isChecked()) {
                            // Do not show the donate dialog again.
                            sharedEditor.putBoolean("show_donate_dialog", false);
                            sharedEditor.apply();
                        }
                        mResume = true;
                        checkNfc();
                    }
                }).setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        if (showDonateDialogCheckBox.isChecked()) {
                            // Do not show the donate dialog again.
                            sharedEditor.putBoolean("show_donate_dialog", false);
                            sharedEditor.apply();
                        }
                        mResume = true;
                        checkNfc();
                    }
                }).show();
        mResume = false;
    }

    // Check if there is Mifare Classic support.
    if (!Common.useAsEditorOnly() && !Common.hasMifareClassicSupport()) {
        // Disable read/write tag options.
        mReadTag.setEnabled(false);
        mWriteTag.setEnabled(false);
        CharSequence styledText = Html.fromHtml(getString(R.string.dialog_no_mfc_support_device));
        AlertDialog ad = new AlertDialog.Builder(this).setTitle(R.string.dialog_no_mfc_support_device_title)
                .setMessage(styledText).setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(R.string.action_exit_app, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                }).setNegativeButton(R.string.action_continue, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        mResume = true;
                        checkNfc();
                    }
                }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        finish();
                    }
                }).show();
        // Make links clickable.
        ((TextView) ad.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
        mResume = false;
    }
}

From source file:me.jreilly.JamesTweet.TweetView.TweetFragment.java

public void setTweet(RealmResults<TweetRealm> mDataset) {

    int i = 0;//from www  .j  a v  a2  s.co  m
    String user_img = mDataset.get(i).getProfileImageUrl();
    final String user_screen = mDataset.get(i).getScreename();
    String media_url = "null";
    Date created = mDataset.get(i).getDate();
    boolean retweeted = mDataset.get(i).isRetweetedStatus();
    String original = mDataset.get(i).getRetweetedBy();
    String username = mDataset.get(i).getName();
    String text = mDataset.get(i).getText();
    final long tId = mDataset.get(i).getId();

    //Load Profile Image
    Picasso.with(mProfileImage.getContext()).load(user_img).transform(new CircleTransform())
            .into(mProfileImage);

    //Set profile image to go to the users profile
    mProfileImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mActivity.swapToProfile(user_screen, mProfileImage);
        }
    });

    final String imageUrl = media_url;
    ViewGroup.LayoutParams params = mImage.getLayoutParams();

    //Set Cropped Media image and zoomImage animation
    if (!imageUrl.equals("null")) {

        mImage.getLayoutParams().height = 400;
        Picasso.with(mImage.getContext()).load(imageUrl).fit().centerCrop().into(mImage);

    } else {
        //Media is not need so it is hidden.
        mImage.setImageDrawable(null);

        mImage.getLayoutParams().height = 0;

    }

    //Set Username Text Field
    Calendar cal = Calendar.getInstance();
    mDate.setText(DateUtils.getRelativeTimeSpanString(created.getTime()));
    mUser.setText(username);
    String tweetText = text;

    //Highlight Profile names/hashtags and their clickable spans
    ArrayList<int[]> hashtagSpans = getSpans(tweetText, '#');
    ArrayList<int[]> profileSpans = getSpans(tweetText, '@');

    SpannableString tweetContent = new SpannableString(tweetText);

    for (int j = 0; j < profileSpans.size(); j++) {
        int[] span = profileSpans.get(j);
        int profileStart = span[0];
        int profileEnd = span[1];

        tweetContent.setSpan(new ProfileLink(mTweet.getContext(), mActivity), profileStart, profileEnd, 0);
    }
    mTweet.setMovementMethod(LinkMovementMethod.getInstance());
    mTweet.setText(tweetContent);
}

From source file:com.vuze.android.remote.fragment.OpenOptionsTagsFragment.java

private void createTags() {
    if (tvTags == null) {
        if (AndroidUtils.DEBUG) {
            Log.e(TAG, "no tvTags");
        }//  w ww .  j  av a 2s. c  o  m
        return;
    }

    List<Map<?, ?>> manualTags = new ArrayList<>();

    List<Map<?, ?>> allTags = sessionInfo.getTags();
    if (allTags == null) {
        return;
    }
    for (Map<?, ?> mapTag : allTags) {
        int type = MapUtils.getMapInt(mapTag, "type", 0);
        if (type == 3) { // manual
            manualTags.add(mapTag);
        }
    }

    tvTags.setMovementMethod(LinkMovementMethod.getInstance());

    SpanTags.SpanTagsListener l = new SpanTags.SpanTagsListener() {
        @Override
        public void tagClicked(Map mapTags, String name) {
            ourActivity.flipTagState(mapTags, name);
        }

        @Override
        public int getTagState(Map mapTag, String name) {
            List<Object> selectedTags = ourActivity.getSelectedTags();
            Object id = MapUtils.getMapObject(mapTag, "uid", name, Object.class);

            return selectedTags.contains(id) ? SpanTags.TAG_STATE_SELECTED : SpanTags.TAG_STATE_UNSELECTED;
        }
    };

    spanTags = new SpanTags(ourActivity, sessionInfo, tvTags, l);
    spanTags.setTagMaps(manualTags);
}

From source file:com.silentcircle.accounts.AccountStep1.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View stepView = inflater.inflate(R.layout.provisioning_bp_s1, container, false);
    if (stepView == null)
        return null;

    ProvisioningActivity.FilterEnter filterEnter = new ProvisioningActivity.FilterEnter();

    mUsernameInput = (EditText) stepView.findViewById(R.id.ProvisioningUsernameInput);
    mUsernameInput.addTextChangedListener(filterEnter);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        mUsernameInput.setBackground(mUsernameInput.getBackground().getConstantState().newDrawable());

    mUsernameLayout = (TextInputLayout) stepView.findViewById(R.id.ProvisioningUsernameLayout);
    mUsernameLayout.setErrorEnabled(true);

    mPasswordInput = (EditText) stepView.findViewById(R.id.ProvisioningPasswordInput);
    mPasswordInput.setTag("current_password");

    mPasswordLayout = (TextInputLayout) stepView.findViewById(R.id.ProvisioningPasswordLayout);
    mPasswordLayout.setErrorEnabled(true);

    mUsernameInput.addTextChangedListener(new TextWatcher() {
        @Override/* w ww  .  j a  v a 2 s.  co  m*/
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            boolean newState = s.toString().contains("@");
            if (newState != loginSso) {
                loginSso = newState;
                updateVisibility();
            }
            mUserValid = checkValid(mUsernameInput, mUsernameLayout, null, false);
            updateLoginButton();
        }
    });

    mUsernameInput.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                // scroll up to try to make sure password field also visible
                scrollViewToTop(mUsernameLayout);
            } else {
                checkValid(mUsernameInput, mUsernameLayout, getString(R.string.provisioning_user_req), false);
            }
        }
    });

    mUsernameInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            return actionId == EditorInfo.IME_ACTION_NEXT && !checkValid(mUsernameInput, mUsernameLayout,
                    getString(R.string.provisioning_user_req), true);
        }
    });

    mPasswordInput.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            mPassValid = checkValid(mPasswordInput, mPasswordLayout, null, false);
            updateLoginButton();
        }
    });

    mPasswordInput.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            // make sure password field visible
            if (!hasFocus) {
                checkValid(mPasswordInput, mPasswordLayout, getString(R.string.provisioning_password_req),
                        false);
            }
        }
    });

    mPasswordInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            return actionId == EditorInfo.IME_ACTION_DONE && !checkValid(mPasswordInput, mPasswordLayout,
                    getString(R.string.provisioning_password_req), true);
        }
    });

    mRegisterNew = (Button) stepView.findViewById(R.id.registerNew);
    mRegisterNew.setOnClickListener(this);

    mLoginExisting = (Button) stepView.findViewById(R.id.loginExisting);
    mLoginExisting.setOnClickListener(this);
    mLoginSavedText = mLoginExisting.getText();

    // FIXME: Remove when account creation is enabled
    // only allow create account when a license code is present
    // the following three lines should be removed when freemium support is to be included in the product
    Bundle args = getArguments();
    if (args == null || TextUtils.isEmpty(args.getString(AuthenticatorActivity.ARG_RONIN_CODE, null)))
        mRegisterNew.setVisibility(View.GONE);

    mShowPassword = (CheckBox) stepView.findViewById(R.id.ShowPassword);
    mShowPassword.setOnClickListener(this);

    mUserFields = (RelativeLayout) stepView.findViewById(R.id.ProvisioningUserFields);

    ((TextView) stepView.findViewById(R.id.ProvisioningVersion)).setText("version " + BuildConfig.VERSION_NAME);

    TextView privacy = (TextView) stepView.findViewById(R.id.ProvisioningPrivacy);
    privacy.setText(Html.fromHtml("<a href=\"https://accounts.silentcircle.com/privacy-policy\">"
            + getResources().getString(R.string.provisioning_privacy) + "</a>"));
    privacy.setMovementMethod(LinkMovementMethod.getInstance());
    stripUnderlines(privacy);

    TextView terms = (TextView) stepView.findViewById(R.id.ProvisioningTerms);
    terms.setText(Html.fromHtml("<a href=\"https://accounts.silentcircle.com/terms\">"
            + getResources().getString(R.string.provisioning_terms) + "</a>"));
    terms.setMovementMethod(LinkMovementMethod.getInstance());
    stripUnderlines(terms);

    mForgotPassword = (TextView) stepView.findViewById(R.id.ProvisioningForgotPassword);
    mForgotPassword.setText(Html.fromHtml("<a href=\"https://accounts.silentcircle.com/account/recover/\">"
            + getResources().getString(R.string.provisioning_forgot_pwd) + "</a>"));
    mForgotPassword.setMovementMethod(LinkMovementMethod.getInstance());
    stripUnderlines(mForgotPassword);

    mScrollView = (ScrollView) stepView.findViewById(R.id.ProvisioningScrollFrameLayout);

    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "fonts/TiemposHeadline-Regular.otf");
    TextView tv = (TextView) stepView.findViewById(R.id.AppText);
    tv.setTypeface(tf);

    stepView.setBackgroundColor(getResources().getColor(R.color.auth_background_grey));

    if (ConfigurationUtilities.mEnableDevDebOptions) {
        mEnvironmentButton = (Button) stepView.findViewById(R.id.switchConfiguration);
        mEnvironmentButton.setVisibility(View.VISIBLE);
        mEnvironmentButton
                .setText(ConfigurationUtilities.mUseDevelopConfiguration ? R.string.switch_to_production
                        : R.string.switch_to_develop);
        mEnvironmentButton.setOnClickListener(this);
    }
    return stepView;
}

From source file:com.r.raul.tools.MainActivity.java

private void msgTraductor() {

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    LayoutInflater inflater = getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.dialog_idiomas, null);
    dialogBuilder.setView(dialogView);/*from   w ww . ja va2  s .  com*/

    final TextView txt0 = (TextView) dialogView.findViewById(R.id.titu0);
    final TextView txt1 = (TextView) dialogView.findViewById(R.id.titu1);
    final TextView txt2 = (TextView) dialogView.findViewById(R.id.titu2);

    String urlM = "<a href=" + getString(R.string.url1_idiomas) + ">" + getString(R.string.p2_idiomas) + "</a>";
    String urlD = "<a href='" + getString(R.string.url2_idiomas) + "'>" + getString(R.string.p3_idiomas)
            + "</a>";

    dialogBuilder.setTitle(R.string.titu_idiomas); //Idiomas Languages
    txt0.setText(R.string.p1_idiomas);
    txt1.setMovementMethod(LinkMovementMethod.getInstance());
    txt2.setMovementMethod(LinkMovementMethod.getInstance());
    txt1.setText(Html.fromHtml(urlM));
    txt2.setText(Html.fromHtml(urlD));

    dialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
        }
    });
    AlertDialog b = dialogBuilder.create();
    b.show();
}

From source file:org.inaturalist.android.GuideDetails.java

private void refreshGuideSideMenu() {

    // Prepare the footer of the guide side menu (description, license, etc.)

    mDownloadingGuide.setVisibility(View.GONE);
    mDownloadGuide.setVisibility(View.VISIBLE);

    if (mGuideXml == null)
        return;//from  www  . j  a v a 2s  .com

    mDescription.setText(Html.fromHtml(mGuideXml.getDescription()));
    mDescription.setMovementMethod(LinkMovementMethod.getInstance());
    mEditorName.setText(mGuideXml.getCompiler());
    mLicense.setText(GuideXML.licenseToText(this, mGuideXml.getLicense()));

    if (mIsDownloading) {
        // Currently downloading guide
        mDownloadingGuide.setVisibility(View.VISIBLE);
        mDownloadingSubtitle.setText(R.string.downloading);
        mDownloadGuide.setVisibility(View.GONE);
        updateDownloadProgress(mDownloadProgress);

    } else if (mGuideXml.isGuideDownloaded()) {
        // Guide was already downloaded
        mDownloadTitle.setText(R.string.downloaded);
        SimpleDateFormat formatter = new SimpleDateFormat();
        mDownloadSubtitle.setText(formatter.format(mGuideXml.getDownloadedGuideDate()));
        mDownloadGuideImage.setImageResource(R.drawable.guide_downloaded);

        mDownloadGuide.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showEditDownloadDialog();
            }
        });

    } else if (!mGuideXml.isOfflineGuideAvailable()) {
        // Download not available
        mDownloadTitle.setText(R.string.download_not_available);
        mDownloadSubtitle.setText(R.string.guide_editor_must_enable_this_feature);
        mDownloadGuideImage.setImageResource(R.drawable.download_guide);
    } else {
        // Download is available
        mDownloadTitle.setText(R.string.download_for_offline_use);
        mDownloadSubtitle.setText(mGuideXml.getNgzFileSize());
        mDownloadGuideImage.setImageResource(R.drawable.download_guide);

        mDownloadGuide.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AlertDialog.Builder builder = new AlertDialog.Builder(GuideDetails.this);
                builder.setTitle(R.string.are_you_sure)
                        .setMessage(String.format(getString(R.string.download_guide_alert),
                                mGuideXml.getNgzFileSize()))
                        .setNegativeButton(getString(R.string.cancel), null)
                        .setPositiveButton(getString(R.string.download), new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                downloadGuide();
                            }
                        }).show();

            }
        });
    }
}

From source file:com.tassadar.multirommgr.MainActivity.java

@TargetApi(20)
private void showDeprecatedLAlert() {
    SpannableString msg = new SpannableString(getString(R.string.deprecated_l_text));
    Linkify.addLinks(msg, Linkify.ALL);/*from   www. java2 s  .c o m*/

    AlertDialog.Builder b = new AlertDialog.Builder(this);
    b.setTitle(R.string.deprecated_l_title).setCancelable(false).setMessage(msg)
            .setNegativeButton(R.string.deprecated_l_btn, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    finish();
                }
            });

    AlertDialog d = b.create();
    d.show();

    TextView msgView = (TextView) d.findViewById(android.R.id.message);
    msgView.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:de.baumann.thema.Screen_Main.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.license) {

        SpannableString s;/*from ww w.  ja v  a 2 s .  c  o m*/

        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
            s = new SpannableString(Html.fromHtml(getString(R.string.about_text), Html.FROM_HTML_MODE_LEGACY));
        } else {
            //noinspection deprecation
            s = new SpannableString(Html.fromHtml(getString(R.string.about_text)));
        }
        Linkify.addLinks(s, Linkify.WEB_URLS);

        final AlertDialog d = new AlertDialog.Builder(Screen_Main.this).setTitle(R.string.about_title)
                .setMessage(s)
                .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).show();
        d.show();
        ((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
    }

    if (id == R.id.changelog) {
        Uri uri = Uri.parse("https://github.com/scoute-dich/Blue-Minimal/blob/master/CHANGELOG.md"); // missing 'http://' will cause crashed
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }

    if (id == R.id.donate) {
        Uri uri = Uri
                .parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP6TGYDYP9SHY"); // missing 'http://' will cause crashed
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }

    return super.onOptionsItemSelected(item);
}

From source file:ru.orangesoftware.financisto2.activity.FlowzrSyncActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FlowzrSyncActivity.me = this;
    mNotifyBuilder = new NotificationCompat.Builder(getApplicationContext());
    nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
    setContentView(R.layout.flowzr_sync);
    restoreUIFromPref();/*from w  w  w . java 2  s .c  o m*/
    if (useCredential != null) {

    }

    AccountManager accountManager = AccountManager.get(getApplicationContext());
    final Account[] accounts = accountManager.getAccountsByType("com.google");
    if (accounts.length < 1) {
        new AlertDialog.Builder(this).setTitle(getString(R.string.flowzr_sync_error))
                .setMessage(R.string.account_required)
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        finish();
                    }
                }).show();
    }
    //radio crendentials
    RadioGroup radioGroupCredentials = (RadioGroup) findViewById(R.id.radioCredentials);
    OnClickListener radio_listener = new OnClickListener() {
        public void onClick(View v) {
            RadioButton radioButtonSelected = (RadioButton) findViewById(v.getId());
            for (Account account : accounts) {
                if (account.name == radioButtonSelected.getText()) {
                    useCredential = account;
                }
            }
        }
    };
    //initialize value
    for (int i = 0; i < accounts.length; i++) {
        RadioButton rb = new RadioButton(this);
        radioGroupCredentials.addView(rb); //, 0, lp); 
        rb.setOnClickListener(radio_listener);
        rb.setText(((Account) accounts[i]).name);
        if (useCredential != null) {
            if (accounts[i].name.equals(useCredential.name)) {
                rb.toggle(); //.setChecked(true);
            }
        }
    }

    bOk = (Button) findViewById(R.id.bOK);
    bOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {

            setRunning();
            initProgressDialog();
            //                if (useCredential!=null) {
            //                   flowzrBilling=new FlowzrBilling(FlowzrSyncActivity.this, getApplicationContext(), http_client, useCredential.toString());  
            //                }               
            if (useCredential == null) {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_choose_account);
                notifyUser(getString(R.string.flowzr_choose_account), 100);
                setReady();
            } else if (!isOnline(FlowzrSyncActivity.this)) {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
                notifyUser(getString(R.string.flowzr_sync_error_no_network), 100);
                setReady();
            } else {
                saveOptionsFromUI();
                //Play Service Billing
                //FlowzrBilling flowzrBilling = new FlowzrBilling(FlowzrSyncActivity.this, getApplicationContext(), http_client, useCredential.toString());  
                //if (flowzrSyncTask.checkSubscription()) {
                flowzrSyncEngine = new FlowzrSyncEngine(FlowzrSyncActivity.this);
                //}

            }
        }
    });

    Button bCancel = (Button) findViewById(R.id.bCancel);
    bCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (flowzrSyncEngine != null) {
                flowzrSyncEngine.isCanceled = true;
            }
            isRunning = false;
            setResult(RESULT_CANCELED);
            setReady();
            startActivity(new Intent(getApplicationContext(), MainActivity.class));
            //finish();
        }
    });

    Button textViewAbout = (Button) findViewById(R.id.buySubscription);
    textViewAbout.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (isOnline(FlowzrSyncActivity.this)) {
                visitFlowzr(useCredential);
            } else {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
            }
        }
    });

    Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr);
    textViewAboutAnon.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (isOnline(FlowzrSyncActivity.this)) {
                visitFlowzr(null);
            } else {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
            }
        }
    });

    TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote);
    textViewNotes.setMovementMethod(LinkMovementMethod.getInstance());
    textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use)));
    if (MyPreferences.isAutoSync(this)) {
        if (checkPlayServices()) {
            gcm = GoogleCloudMessaging.getInstance(this);
            regid = getRegistrationId(getApplicationContext());

            if (regid.equals("")) {
                registerInBackground();
            }
            Log.i(TAG, "Google Cloud Messaging registered as :" + regid);
        } else {
            Log.i(TAG, "No valid Google Play Services APK found.");
        }
    }
}