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:com.flowzr.activity.FlowzrSyncActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.flowzr_sync);

    //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, 
    //only way found to remove on various devices 2.3x, 3.0, ...
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212")));

    renderLastTime();/*  w ww  . ja va2s.  com*/

    CheckBox chkForce = (CheckBox) findViewById(R.id.chk_sync_from_zero);
    chkForce.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            resetLastTime();
            renderLastTime();
        }
    });
    Button syncButton = (Button) findViewById(R.id.sync);
    syncButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startSync();
        }
    });

    Button textViewAbout = (Button) findViewById(R.id.buySubscription);
    textViewAbout.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String accountName = MyPreferences.getFlowzrAccount(getApplicationContext());
            if (accountName == null) {
                Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_choose_account, Toast.LENGTH_SHORT)
                        .show();
                return;

            }
            if (isOnline(FlowzrSyncActivity.this)) {
                //checkPlayServices();    
            } else {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
                return;
            }
            //
            Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_sync_auth_inprogress, Toast.LENGTH_SHORT)
                    .show();
            FlowzrBillTask ft = new FlowzrBillTask(FlowzrSyncActivity.this);
            ft.execute();
            //visitFlowzr(accountName);
        }
    });

    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.");
        }
    }
}

From source file:com.github.pockethub.ui.comment.CommentListAdapter.java

@Override
protected View initialize(int type, View view) {
    view = super.initialize(type, view);

    textView(view, 0).setMovementMethod(LinkMovementMethod.getInstance());
    return view;/* w w w  .  jav a 2  s  .c  om*/
}

From source file:no.kreativo.badetemperaturer.MainActivity.java

private void showAboutPopup() {

    final AlertDialog dialog = new AlertDialog.Builder(this).setTitle(getResources().getString(R.string.about))
            .setMessage(Html.fromHtml(/*from w w  w  .  j ava  2 s  . co m*/
                    "<a href=\"http://www.yr.no/observasjonar/badetemperaturar.html\n\">Badetemperaturene blir "
                            + "rapportert til yr.no og Reiseradioen av hver enkelt campingplass/badestrand. Mlingene flger ikke vanlig "
                            + "meteorologisk standard, men gir en god indikasjon p vanntemperaturen. Badetemperaturene i Oslo er levert "
                            + "av Oslo kommune, Akershus av badevann.no.</a>"))
            .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
    dialog.show();

    ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());

}

From source file:com.flowzr.budget.holo.activity.FlowzrSyncActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.flowzr_sync);

    //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line,
    //only way found to remove on various devices 2.3x, 3.0, ...
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#121212")));

    renderLastTime();/* ww  w  . j  a  v  a 2s.c o  m*/

    CheckBox chkForce = (CheckBox) findViewById(R.id.chk_sync_from_zero);
    chkForce.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            resetLastTime();
            renderLastTime();
        }
    });
    Button syncButton = (Button) findViewById(R.id.sync);
    syncButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startSync();
        }
    });

    Button textViewAbout = (Button) findViewById(R.id.buySubscription);
    textViewAbout.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String accountName = MyPreferences.getFlowzrAccount(getApplicationContext());
            if (accountName == null) {
                Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_choose_account, Toast.LENGTH_SHORT)
                        .show();
                return;

            }
            if (isOnline(FlowzrSyncActivity.this)) {
                //checkPlayServices();
            } else {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
                return;
            }
            //
            Toast.makeText(FlowzrSyncActivity.this, R.string.flowzr_sync_auth_inprogress, Toast.LENGTH_SHORT)
                    .show();
            FlowzrBillTask ft = new FlowzrBillTask(FlowzrSyncActivity.this);
            ft.execute();
            //visitFlowzr(accountName);
        }
    });

    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.");
        }
    }
}

From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderAnyMemo.java

@Override
protected void fetchDatabase(final DownloadItem di) {
    final Thread downloadThread = new Thread() {
        @Override/*  w  w  w .j  a  v a2s.com*/
        public void run() {
            String filename = di.getExtras("filename");
            try {
                downloadDatabase(di);
                filename = filename.replace(".zip", ".db");
                String sdpath = Environment.getExternalStorageDirectory().getAbsolutePath()
                        + getString(R.string.default_dir);
                final File dbFile = new File(sdpath + filename);
                mHandler.post(new Runnable() {
                    public void run() {
                        new AlertDialog.Builder(DownloaderAnyMemo.this)
                                .setTitle(R.string.downloader_download_success)
                                .setMessage(getString(R.string.downloader_download_success_message)
                                        + dbFile.toString())
                                .setPositiveButton(R.string.ok_text, null).create().show();
                    }
                });
            } catch (final Exception e) {
                mHandler.post(new Runnable() {
                    public void run() {
                        new AlertDialog.Builder(DownloaderAnyMemo.this)
                                .setTitle(R.string.downloader_download_fail)
                                .setMessage(getString(R.string.downloader_download_fail_message) + " "
                                        + e.toString())
                                .setPositiveButton(R.string.ok_text, null).create().show();
                    }
                });
            }
        }
    };
    View alertView = View.inflate(DownloaderAnyMemo.this, R.layout.link_alert, null);
    TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setText(
            Html.fromHtml(getString(R.string.downloader_download_alert_message) + di.getDescription()));

    new AlertDialog.Builder(this).setView(alertView)
            .setTitle(getString(R.string.downloader_download_alert) + di.getExtras("filename"))
            .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface arg0, int arg1) {
                    downloadThread.start();
                }
            }).setNegativeButton(getString(R.string.no_text), null).show();

}

From source file:org.mozilla.gecko.home.HistoryPanel.java

private void updateUiFromCursor(Cursor c) {
    if (c != null && c.getCount() > 0) {
        if (RestrictedProfiles.isAllowed(getActivity(), Restriction.DISALLOW_CLEAR_HISTORY)) {
            mClearHistoryButton.setVisibility(View.VISIBLE);
        }//from   ww w.  j a v  a2  s .  c  o m
        return;
    }

    // Cursor is empty, so hide the "Clear browsing history" button,
    // and set the empty view if it hasn't been set already.
    mClearHistoryButton.setVisibility(View.GONE);

    if (mEmptyView == null) {
        // Set empty panel view. We delay this so that the empty view won't flash.
        final ViewStub emptyViewStub = (ViewStub) getView().findViewById(R.id.home_empty_view_stub);
        mEmptyView = emptyViewStub.inflate();

        final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image);
        emptyIcon.setImageResource(R.drawable.icon_most_recent_empty);

        final TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text);
        emptyText.setText(R.string.home_most_recent_empty);

        final TextView emptyHint = (TextView) mEmptyView.findViewById(R.id.home_empty_hint);
        final String hintText = getResources().getString(R.string.home_most_recent_emptyhint);

        final SpannableStringBuilder hintBuilder = formatHintText(hintText);
        if (hintBuilder != null) {
            emptyHint.setText(hintBuilder);
            emptyHint.setMovementMethod(LinkMovementMethod.getInstance());
            emptyHint.setVisibility(View.VISIBLE);
        }

        mList.setEmptyView(mEmptyView);
    }
}

From source file:com.abcvoipsip.ui.prefs.CodecsFragment.java

@Override
@SuppressWarnings("unchecked")
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {/*from w ww .j a va2s .c om*/
        info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
        Log.e(THIS_FILE, "bad menuInfo", e);
        return false;
    }

    HashMap<String, Object> codec = null;
    codec = (HashMap<String, Object>) mAdapter.getItem(info.position);

    if (codec == null) {
        // If for some reason the requested item isn't available, do nothing
        return false;
    }
    int selId = item.getItemId();
    if (selId == MENU_ITEM_ACTIVATE) {
        boolean isDisabled = ((Short) codec.get(CODEC_PRIORITY) == 0);
        final short newPrio = isDisabled ? (short) 1 : (short) 0;
        if (NON_FREE_CODECS.containsKey(codec.get(CODEC_ID)) && isDisabled) {
            final HashMap<String, Object> fCodec = codec;

            final TextView message = new TextView(getActivity());
            final SpannableString s = new SpannableString(
                    getString(R.string.this_codec_is_not_free) + NON_FREE_CODECS.get(codec.get(CODEC_ID)));
            Linkify.addLinks(s, Linkify.WEB_URLS);
            message.setText(s);
            message.setMovementMethod(LinkMovementMethod.getInstance());
            message.setPadding(10, 10, 10, 10);

            //Alert user that we will disable for all incoming calls as he want to quit
            new AlertDialog.Builder(getActivity()).setTitle(R.string.warning).setView(message)
                    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            setCodecActivated(fCodec, newPrio);
                        }
                    }).setNegativeButton(R.string.cancel, null).show();
        } else {
            setCodecActivated(codec, newPrio);
        }
        return true;
    }
    return false;
}

From source file:org.thoughtcrime.securesms.logsubmit.SubmitLogFragment.java

private TextView handleBuildSuccessTextView(final String logUrl) {
    TextView showText = new TextView(getActivity());

    showText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    showText.setPadding(15, 30, 15, 30);
    showText.setText(getString(R.string.log_submit_activity__copy_this_url_and_add_it_to_your_issue, logUrl));
    showText.setAutoLinkMask(Activity.RESULT_OK);
    showText.setMovementMethod(LinkMovementMethod.getInstance());
    showText.setOnLongClickListener(new View.OnLongClickListener() {

        @Override//from   w w  w.j a  v  a2 s. c  o  m
        public boolean onLongClick(View v) {
            @SuppressWarnings("deprecation")
            ClipboardManager manager = (ClipboardManager) getActivity()
                    .getSystemService(Activity.CLIPBOARD_SERVICE);
            manager.setText(logUrl);
            Toast.makeText(getActivity(), R.string.log_submit_activity__copied_to_clipboard, Toast.LENGTH_SHORT)
                    .show();
            return true;
        }
    });

    Linkify.addLinks(showText, Linkify.WEB_URLS);
    return showText;
}

From source file:org.liberty.android.fantastischmemo.ui.AnyMemo.java

private void prepareFirstTimeRun() {
    File sdPath = new File(AMEnv.DEFAULT_ROOT_PATH);
    //Check the version, if it is updated from an older version it will show a dialog
    int savedVersionCode = settings.getInt(AMPrefKeys.SAVED_VERSION_CODE_KEY, 1);

    int thisVersionCode;
    try {/*from www  . jav a 2  s . co  m*/
        thisVersionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        thisVersionCode = 0;
        assert false : "The version code can not be retrieved. Is it defined in build.gradle?";
    }

    boolean firstTime = settings.getBoolean(AMPrefKeys.FIRST_TIME_KEY, true);

    // Force clean preference for non-compstible versions.
    if (savedVersionCode < 154) { // Version 9.0.4
        firstTime = true;
        SharedPreferences.Editor editor = settings.edit();
        editor.clear();
        editor.commit();
    }

    /* First time installation! It will install the sample db
     * to /sdcard/AnyMemo
     */
    if (firstTime == true) {
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(AMPrefKeys.FIRST_TIME_KEY, false);
        editor.putString(AMPrefKeys.getRecentPathKey(0), AMEnv.DEFAULT_ROOT_PATH + AMEnv.DEFAULT_DB_NAME);
        editor.commit();
        try {
            amFileUtil.copyFileFromAsset(AMEnv.DEFAULT_DB_NAME, new File(sdPath + "/" + AMEnv.DEFAULT_DB_NAME));

            InputStream in2 = getResources().getAssets().open(AMEnv.EMPTY_DB_NAME);
            String emptyDbPath = getApplicationContext().getFilesDir().getAbsolutePath() + "/"
                    + AMEnv.EMPTY_DB_NAME;
            FileUtils.copyInputStreamToFile(in2, new File(emptyDbPath));
            in2.close();
        } catch (IOException e) {
            Log.e(TAG, "Copy file error", e);

        }
    }
    /* Detect an update */
    if (savedVersionCode != thisVersionCode) {
        SharedPreferences.Editor editor = settings.edit();
        /* save new version number */
        editor.putInt(AMPrefKeys.SAVED_VERSION_CODE_KEY, thisVersionCode);
        editor.commit();

        View alertView = View.inflate(this, R.layout.link_alert, null);
        TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message);
        textView.setText(Html.fromHtml(getString(R.string.what_is_new_message)));
        textView.setMovementMethod(LinkMovementMethod.getInstance());
        new AlertDialog.Builder(this).setView(alertView).setTitle(getString(R.string.what_is_new))
                .setPositiveButton(getString(R.string.ok_text), null)
                .setNegativeButton(getString(R.string.about_version), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        Intent myIntent = new Intent();
                        myIntent.setAction(Intent.ACTION_VIEW);
                        myIntent.addCategory(Intent.CATEGORY_BROWSABLE);
                        myIntent.setData(Uri.parse(WEBSITE_VERSION));
                        startActivity(myIntent);
                    }
                }).show();
    }
}

From source file:org.schabi.newpipe.detail.VideoItemDetailFragment.java

private void updateInfo(final StreamInfo info) {
    Activity a = getActivity();//  w  w w .  j ava  2  s .c o m

    RelativeLayout textContentLayout = (RelativeLayout) activity.findViewById(R.id.detail_text_content_layout);
    final TextView videoTitleView = (TextView) activity.findViewById(R.id.detail_video_title_view);
    TextView uploaderView = (TextView) activity.findViewById(R.id.detail_uploader_view);
    TextView viewCountView = (TextView) activity.findViewById(R.id.detail_view_count_view);
    TextView thumbsUpView = (TextView) activity.findViewById(R.id.detail_thumbs_up_count_view);
    TextView thumbsDownView = (TextView) activity.findViewById(R.id.detail_thumbs_down_count_view);
    TextView uploadDateView = (TextView) activity.findViewById(R.id.detail_upload_date_view);
    TextView descriptionView = (TextView) activity.findViewById(R.id.detail_description_view);
    RecyclerView nextStreamView = (RecyclerView) activity.findViewById(R.id.detail_next_stream_content);
    RelativeLayout nextVideoRootFrame = (RelativeLayout) activity
            .findViewById(R.id.detail_next_stream_root_layout);
    TextView similarTitle = (TextView) activity.findViewById(R.id.detail_similar_title);
    Button backgroundButton = (Button) activity
            .findViewById(R.id.detail_stream_thumbnail_window_background_button);
    View topView = activity.findViewById(R.id.detailTopView);
    Button channelButton = (Button) activity.findViewById(R.id.channel_button);

    // prevents a crash if the activity/fragment was already left when the response came
    if (channelButton != null) {

        progressBar.setVisibility(View.GONE);
        if (info.next_video != null) {
            // todo: activate this function or remove it
            nextStreamView.setVisibility(View.GONE);
        } else {
            nextStreamView.setVisibility(View.GONE);
            activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
        }

        textContentLayout.setVisibility(View.VISIBLE);
        if (android.os.Build.VERSION.SDK_INT < 18) {
            playVideoButton.setVisibility(View.VISIBLE);
        } else {
            ImageView playArrowView = (ImageView) activity.findViewById(R.id.play_arrow_view);
            playArrowView.setVisibility(View.VISIBLE);
        }

        if (!showNextStreamItem) {
            nextVideoRootFrame.setVisibility(View.GONE);
            similarTitle.setVisibility(View.GONE);
        }

        videoTitleView.setText(info.title);

        topView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
                    ImageView arrow = (ImageView) activity.findViewById(R.id.toggle_description_view);
                    View extra = activity.findViewById(R.id.detailExtraView);
                    if (extra.getVisibility() == View.VISIBLE) {
                        extra.setVisibility(View.GONE);
                        arrow.setImageResource(R.drawable.arrow_down);
                    } else {
                        extra.setVisibility(View.VISIBLE);
                        arrow.setImageResource(R.drawable.arrow_up);
                    }
                }
                return true;
            }
        });

        // Since newpipe is designed to work even if certain information is not available,
        // the UI has to react on missing information.
        videoTitleView.setText(info.title);
        if (!info.uploader.isEmpty()) {
            uploaderView.setText(info.uploader);
        } else {
            activity.findViewById(R.id.detail_uploader_view).setVisibility(View.GONE);
        }
        if (info.view_count >= 0) {
            viewCountView.setText(Localization.localizeViewCount(info.view_count, a));
        } else {
            viewCountView.setVisibility(View.GONE);
        }
        if (info.dislike_count >= 0) {
            thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, a));
        } else {
            thumbsDownView.setVisibility(View.INVISIBLE);
            activity.findViewById(R.id.detail_thumbs_down_count_view).setVisibility(View.GONE);
        }
        if (info.like_count >= 0) {
            thumbsUpView.setText(Localization.localizeNumber(info.like_count, a));
        } else {
            thumbsUpView.setVisibility(View.GONE);
            activity.findViewById(R.id.detail_thumbs_up_img_view).setVisibility(View.GONE);
            thumbsDownView.setVisibility(View.GONE);
            activity.findViewById(R.id.detail_thumbs_down_img_view).setVisibility(View.GONE);
        }
        if (!info.upload_date.isEmpty()) {
            uploadDateView.setText(Localization.localizeDate(info.upload_date, a));
        } else {
            uploadDateView.setVisibility(View.GONE);
        }
        if (!info.description.isEmpty()) {
            descriptionView.setText(Html.fromHtml(info.description));
        } else {
            descriptionView.setVisibility(View.GONE);
        }

        descriptionView.setMovementMethod(LinkMovementMethod.getInstance());

        // parse streams
        Vector<VideoStream> streamsToUse = new Vector<>();
        for (VideoStream i : info.video_streams) {
            if (useStream(i, streamsToUse)) {
                streamsToUse.add(i);
            }
        }

        textContentLayout.setVisibility(View.VISIBLE);

        if (info.next_video == null) {
            activity.findViewById(R.id.detail_next_stream_title).setVisibility(View.GONE);
        }

        if (info.related_streams != null && !info.related_streams.isEmpty()) {
            initSimilarVideos(info);
        } else {
            activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
            activity.findViewById(R.id.similar_streams_view).setVisibility(View.GONE);
        }

        setupActionBarHandler(info);

        if (autoPlayEnabled) {
            playVideo(info);
        }

        if (android.os.Build.VERSION.SDK_INT < 18) {
            playVideoButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    playVideo(info);
                }
            });
        }

        backgroundButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                playVideo(info);
            }
        });

        if (info.channel_url != null && info.channel_url != "") {
            channelButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent i = new Intent(activity, ChannelActivity.class);
                    i.putExtra(ChannelActivity.CHANNEL_URL, info.channel_url);
                    i.putExtra(ChannelActivity.SERVICE_ID, info.service_id);
                    startActivity(i);
                }
            });
        } else {
            channelButton.setVisibility(Button.GONE);
        }

        initThumbnailViews(info);
    }
}