List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:com.ntsync.android.sync.activities.KeyPasswordActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); SystemHelper.initSystem(this); Log.i(TAG, "loading data from Intent"); final Intent intent = getIntent(); mUsername = intent.getStringExtra(PARAM_USERNAME); pwdSalt = intent.getByteArrayExtra(PARAM_SALT); pwdCheck = intent.getByteArrayExtra(PARAM_CHECK); requestWindowFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.keypassword_activity); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.key); mMessage = (TextView) findViewById(R.id.message_bottom); mPasswordEdit = new AutoCompleteTextView[5]; mPasswordEdit[0] = (AutoCompleteTextView) findViewById(R.id.pwd1_edit); mPasswordEdit[1] = (AutoCompleteTextView) findViewById(R.id.pwd2_edit); mPasswordEdit[2] = (AutoCompleteTextView) findViewById(R.id.pwd3_edit); mPasswordEdit[3] = (AutoCompleteTextView) findViewById(R.id.pwd4_edit); mPasswordEdit[4] = (AutoCompleteTextView) findViewById(R.id.pwd5_edit); for (AutoCompleteTextView textView : mPasswordEdit) { textView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_PASSWORD); }/*from w w w .j a va2 s. c om*/ if (pwdSalt == null || pwdSalt.length != ClientKeyHelper.SALT_LENGHT || pwdCheck == null) { // disable password input for (AutoCompleteTextView textView : mPasswordEdit) { if (textView != null) { textView.setEnabled(false); } } } msgNewKey = (TextView) findViewById(R.id.message_newkey); SpannableString newKeyText = SpannableString.valueOf(getText(R.string.keypwd_activity_newkey_label)); newKeyText.setSpan(new InternalURLSpan(this), 0, newKeyText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); msgNewKey.setText(newKeyText, BufferType.SPANNABLE); msgNewKey.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.ijuru.kumva.app.activity.EntryActivity.java
/** * Sets the text of a text view or hides it if the text is empty * @param itemId the text view identifier * @param text the text//from ww w . j a v a2s . c om */ protected void setItemTextOrHide(int itemId, CharSequence text) { TextView view = (TextView) findViewById(itemId); view.setMovementMethod(LinkMovementMethod.getInstance()); if (!TextUtils.isEmpty(text)) { view.setText(text); } else { view.setVisibility(View.GONE); } }
From source file:com.murrayc.galaxyzoo.app.ZooFragment.java
private void showAbout() { final Activity activity = getActivity(); final AlertDialog.Builder builder = new AlertDialog.Builder(activity); // Get the layout inflater final LayoutInflater inflater = activity.getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout final View view = inflater.inflate(R.layout.about, null); builder.setView(view);/*from ww w .j a v a2 s .com*/ final TextView textView = (TextView) view.findViewById(R.id.textViewAbout); if (textView == null) { Log.error("showAbout: textView was null."); return; } //This voodoo makes the textviews' HTML links clickable: //See http://stackoverflow.com/questions/2734270/how-do-i-make-links-in-a-textview-clickable/20647011#20647011 textView.setMovementMethod(LinkMovementMethod.getInstance()); final String versionText = String.format(getString(R.string.about_version_text_format), BuildConfig.VERSION_NAME); //The about dialog's text is split into multiple strings to make translation easier, //so we need to concatenate them here. //Note that we use getText(), not getString(), //so we don't lose the <a href=""> links. //Likewise, we use SpannableStringBuilder instead of StringBuilder, //because we lose the links when using StringBuilder. final SpannableStringBuilder strBuilder = new SpannableStringBuilder(); final String PARAGRAPH_BREAK = "\n\n"; strBuilder.append(versionText); strBuilder.append(PARAGRAPH_BREAK); strBuilder.append(getText(R.string.about_text1)); strBuilder.append(PARAGRAPH_BREAK); strBuilder.append(getText(R.string.about_text2)); strBuilder.append(PARAGRAPH_BREAK); strBuilder.append(getText(R.string.about_text3)); strBuilder.append(PARAGRAPH_BREAK); strBuilder.append(getText(R.string.about_text3b)); strBuilder.append(PARAGRAPH_BREAK); strBuilder.append(getText(R.string.about_text4)); strBuilder.append(PARAGRAPH_BREAK); strBuilder.append(getText(R.string.about_text5)); strBuilder.append(PARAGRAPH_BREAK); strBuilder.append(getText(R.string.about_text6)); textView.setText(strBuilder); /* We used to put the version text into a separate TextView, but when the about text in textView is too long, the scroll never reaches this far. It does work when we add it to first regular textView. */ /* final TextView textViewVersion = (TextView) view.findViewById(R.id.textViewVersion); if (textViewVersion != null) { textViewVersion.setText(versionText); } */ final AlertDialog dialog = builder.create(); dialog.setTitle(R.string.app_name); dialog.setIcon(R.mipmap.ic_launcher); dialog.show(); }
From source file:org.sirimangalo.meditationplus.AdapterChat.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { View rowView;/*from w w w . j a v a 2 s.com*/ if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater.inflate(R.layout.list_item_chat, parent, false); } else { rowView = convertView; } JSONObject p = values.get(position); try { int then = Integer.parseInt(p.getString("time")); long nowL = System.currentTimeMillis() / 1000; int now = (int) nowL; int ela = now - then; int day = 60 * 60 * 24; ela = ela > day ? day : ela; int intColor = 255 - Math.round((float) ela * 255 / day); intColor = intColor > 100 ? intColor : 100; String hexTransparency = Integer.toHexString(intColor); hexTransparency = hexTransparency.length() > 1 ? hexTransparency : "0" + hexTransparency; String hexColor = "#" + hexTransparency + "000000"; int transparency = Color.parseColor(hexColor); TextView time = (TextView) rowView.findViewById(R.id.time); if (time != null) { String ts = null; ts = Utils.time2Ago(then); time.setText(ts); time.setTextColor(transparency); } TextView mess = (TextView) rowView.findViewById(R.id.message); if (mess != null) { final String username = p.getString("username"); String messageString = p.getString("message"); messageString = Html.fromHtml(messageString).toString(); SpannableString messageSpan = Utils.replaceSmilies(context, messageString, intColor); if (messageString.contains("@" + loggedUser)) { int index = messageString.indexOf("@" + loggedUser); messageSpan.setSpan(new StyleSpan(Typeface.BOLD), index, index + loggedUser.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); messageSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "990000")), index, index + loggedUser.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } for (String user : users) { if (!user.equals(loggedUser) && messageString.contains("@" + user)) { int index = messageString.indexOf("@" + user); messageSpan = Utils.createProfileSpan(context, index, index + user.length() + 1, user, messageSpan); messageSpan.setSpan( new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "009900")), index, index + user.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } Spannable userSpan = Utils.createProfileSpan(context, 0, username.length(), username, new SpannableString(username + ": ")); if (p.getString("me").equals("true")) userSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "0000FF")), 0, userSpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); else userSpan.setSpan(new ForegroundColorSpan(Color.parseColor("#" + hexTransparency + "000000")), 0, userSpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); CharSequence full = TextUtils.concat(userSpan, messageSpan); mess.setTextColor(transparency); mess.setText(full); mess.setMovementMethod(LinkMovementMethod.getInstance()); Linkify.addLinks(mess, Linkify.ALL); mess.setTag(p.getString("cid")); } } catch (JSONException e) { e.printStackTrace(); } return rowView; }
From source file:com.limewoodmedia.nsdroid.activities.Region.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.region);/*from ww w .jav a 2 s . c o m*/ // Fetch flag LoadingHelper.loadHomeFlag(this); imageLoader = Utils.getImageLoader(this); this.options = Utils.getImageLoaderDisplayOptions(); ActionBar actionBar = getSupportActionBar(); actionBar.setHomeButtonEnabled(true); Utils.setupNavigationDrawer(this); viewPager = (ViewPager) findViewById(R.id.pager); // WFE wfe = (ViewGroup) getLayoutInflater().inflate(R.layout.region_wfe, viewPager, false); regionName = (TextView) wfe.findViewById(R.id.region_name); flag = (ImageView) wfe.findViewById(R.id.region_flag); delegate = (TextView) wfe.findViewById(R.id.region_delegate); founder = (TextView) wfe.findViewById(R.id.region_founder); text = (TextView) wfe.findViewById(R.id.wfe); delegate.setMovementMethod(LinkMovementMethod.getInstance()); founder.setMovementMethod(LinkMovementMethod.getInstance()); text.setMovementMethod(LinkMovementMethod.getInstance()); fieldset = (ViewGroup) wfe.findViewById(R.id.fieldset); header = (TextView) wfe.findViewById(R.id.wfe_header); ViewTreeObserver observer = header.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { fieldset.setPadding(fieldset.getPaddingLeft(), header.getHeight() - (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, getResources().getDisplayMetrics()), fieldset.getPaddingRight(), fieldset.getPaddingBottom()); } }); layout = (ViewGroup) wfe.findViewById(R.id.region_layout); // RMB rmb = (ViewGroup) getLayoutInflater().inflate(R.layout.rmb_single, viewPager, false); rmbInner = (RMBFragment) getSupportFragmentManager().findFragmentById(R.id.rmb); rmbRegion = (TextView) rmb.findViewById(R.id.rmb_region_name); // Page navigation previous = (ImageView) rmb.findViewById(R.id.rmb_previous); previous.setOnClickListener(rmbClickListener); page = (ImageView) rmb.findViewById(R.id.rmb_page); page.setOnClickListener(rmbClickListener); next = (ImageView) rmb.findViewById(R.id.rmb_next); next.setOnClickListener(rmbClickListener); // Officers officers = (ViewGroup) getLayoutInflater().inflate(R.layout.officers_single, viewPager, false); officersTitle = (TextView) officers.findViewById(R.id.officers_title); officersInner = (OfficersFragment) getSupportFragmentManager().findFragmentById(R.id.officers); // Embassies embassies = (ViewGroup) getLayoutInflater().inflate(R.layout.embassies_single, viewPager, false); embassiesTitle = (TextView) embassies.findViewById(R.id.embassies_title); embassiesInner = (EmbassiesFragment) getSupportFragmentManager().findFragmentById(R.id.embassies); // Set up view pager viewPager.setAdapter(new RegionPagerAdapter()); viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { // Update context menu supportInvalidateOptionsMenu(); } @Override public void onPageScrollStateChanged(int state) { } }); // Check if going straight to RMB / Embassies if (getIntent().hasExtra("page")) { viewPager.setCurrentItem(getIntent().getIntExtra("page", 0), false); } Log.d(TAG, "DATA " + getIntent().getDataString()); if (getIntent().getData() == null) { // Get user's region homeRegion = true; region = NationInfo.getInstance(this).getRegionId(); } else { String dataStr = getIntent().getDataString(); if (dataStr.startsWith("com.limewoodMedia.nsdroid.region.rmb://")) { region = dataStr.replace("com.limewoodMedia.nsdroid.region.rmb://", ""); viewPager.setCurrentItem(1, false); } else if (dataStr.startsWith("com.limewoodMedia.nsdroid.region.embassies://")) { region = dataStr.replace("com.limewoodMedia.nsdroid.region.embassies://", ""); viewPager.setCurrentItem(2, false); } else if (dataStr.startsWith("com.limewoodMedia.nsdroid.region://")) { region = dataStr.replace("com.limewoodMedia.nsdroid.region://", ""); } } rmbInner.setRegionName(region); officersInner.setRegionName(region); embassiesInner.setRegionName(region); // if(savedInstanceState == null) { loadRegion(); // } else { // // Restore state // data = savedInstanceState.getParcelable("region_data"); // doSetup(); // } }
From source file:com.syncedsynapse.kore2.ui.hosts.AddHostFragmentZeroconf.java
/** * Starts the service discovery, setting up the UI accordingly *//* w ww . j a v a 2 s . c om*/ public void startSearching() { LogUtils.LOGD(TAG, "Starting service discovery..."); searchCancelled = false; final Handler handler = new Handler(); final Thread searchThread = new Thread(new Runnable() { @Override public void run() { WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); WifiManager.MulticastLock multicastLock = null; try { // Get wifi ip address int wifiIpAddress = wifiManager.getConnectionInfo().getIpAddress(); InetAddress wifiInetAddress = NetUtils.intToInetAddress(wifiIpAddress); // Acquire multicast lock multicastLock = wifiManager.createMulticastLock("kore2.multicastlock"); multicastLock.setReferenceCounted(false); multicastLock.acquire(); JmDNS jmDns = (wifiInetAddress != null) ? JmDNS.create(wifiInetAddress) : JmDNS.create(); // Get the json rpc service list final ServiceInfo[] serviceInfos = jmDns.list(MDNS_XBMC_SERVICENAME, DISCOVERY_TIMEOUT); synchronized (lock) { // If the user didn't cancel the search, and we are sill in the activity if (!searchCancelled && isAdded()) { handler.post(new Runnable() { @Override public void run() { if ((serviceInfos == null) || (serviceInfos.length == 0)) { noHostFound(); } else { foundHosts(serviceInfos); } } }); } } } catch (IOException e) { LogUtils.LOGD(TAG, "Got an IO Exception", e); } finally { if (multicastLock != null) multicastLock.release(); } } }); titleTextView.setText(R.string.searching); messageTextView.setText(Html.fromHtml(getString(R.string.wizard_search_message))); messageTextView.setMovementMethod(LinkMovementMethod.getInstance()); progressBar.setVisibility(View.VISIBLE); hostListGridView.setVisibility(View.GONE); // Setup buttons nextButton.setVisibility(View.INVISIBLE); previousButton.setVisibility(View.VISIBLE); previousButton.setText(android.R.string.cancel); previousButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { synchronized (lock) { searchCancelled = true; noHostFound(); } } }); searchThread.start(); }
From source file:org.inftel.ssa.mobile.ui.fragments.ProjectDetailFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data.moveToFirst()) { mProjectId = data.getString(data.getColumnIndex(Projects._ID)); name = data.getString(data.getColumnIndex(Projects.PROJECT_NAME)); summary = data.getString(data.getColumnIndex(Projects.PROJECT_SUMMARY)); description = data.getString(data.getColumnIndex(Projects.PROJECT_DESCRIPTION)); opened = data.getString(data.getColumnIndex(Projects.PROJECT_OPENED)); started = data.getString(data.getColumnIndex(Projects.PROJECT_STARTED)); closed = data.getString(data.getColumnIndex(Projects.PROJECT_CLOSE)); company = data.getString(data.getColumnIndex(Projects.PROJECT_COMPANY)); license = data.getString(data.getColumnIndex(Projects.PROJECT_LICENSE)); labels = data.getString(data.getColumnIndex(Projects.PROJECT_LABELS)); links = data.getString(data.getColumnIndex(Projects.PROJECT_LINKS)); // taskChart(mProjectId); // Update UI mHandler.post(new Runnable() { public void run() { // Header ((TextView) getView().findViewById(R.id.detail_title)).setText(name); ((TextView) getView().findViewById(R.id.detail_subtitle)).setText(summary); // Tab description if (description != null) { ((TextView) getView().findViewById(R.id.project_detail_description)) .setText(Html.fromHtml(description)); }/*from ww w. java 2 s. c om*/ // Tab links // TODO Ver como llegan los links y aplicarle formato String link = "<a href='http://www.masterinftel.uma.es/'>Master Inftel</a>"; TextView l = (TextView) getView().findViewById(R.id.empty_links); l.setText(Html.fromHtml(link)); l.setMovementMethod(LinkMovementMethod.getInstance()); l.setLinksClickable(true); // Tab Information ((TextView) getView().findViewById(R.id.lblOpened)).setText(formatDate(opened)); ((TextView) getView().findViewById(R.id.lblStarted)).setText(formatDate(started)); ((TextView) getView().findViewById(R.id.lblClosed)).setText(formatDate(closed)); ((TextView) getView().findViewById(R.id.lblCompany)).setText(company); ((TextView) getView().findViewById(R.id.lblLicense)).setText(license); ((TextView) getView().findViewById(R.id.lblLabels)).setText(labels); } }); } }
From source file:org.gearvrf.weartouchpad.WearStatusActivity.java
private void showAboutDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.about_message).setTitle(R.string.about_title) .setIcon(android.R.drawable.ic_menu_info_details); AlertDialog dialog = builder.create(); dialog.show();//from w ww .j a va 2 s . c o m ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.dodo.wbbshoutbox.codebot.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); context = getApplicationContext();// w w w .j a v a2 s .c om checkUpdate(); Request.client.setUserAgent("Dodo Shoutboxapp"); myCookieStore = new PersistentCookieStore(this); Request.client.setCookieStore(myCookieStore); Usernamefield = (TextView) findViewById(R.id.txtUsername); Sendbutton = (Button) findViewById(R.id.cmdSend); Refreshbutton = (Button) findViewById(R.id.cmdRefresh); pbReadChat = (ProgressBar) findViewById(R.id.pbReadChat); lblVerlauf = (TextView) findViewById(R.id.lblVerlauf); lblAutoRefresh = (TextView) findViewById(R.id.lblAutorefresh); if (UserData.readPref("textsize", this).equals("")) { UserData.writePref("textsize", "10", this); } if (UserData.readPref("refreshcircle", this).equals("")) { UserData.writePref("refreshcircle", "1", this); refreshanimation = 1; } else if (UserData.readPref("refreshcircle", this).equals("1")) { refreshanimation = 1; } /* * if(UserData.readPref("changechatdirection", this).equals("")) { * UserData.writePref("changechatdirection", "0", this); } else * if(UserData.readPref("changechatdirection", this).equals("1")) { * changechatdirection = 1; } */ if (UserData.readPref("showtime", this).equals("")) { UserData.writePref("showtime", "1", this); } else { showTime = Integer.valueOf(UserData.readPref("showtime", this)); } if (!UserData.readPref("username", this).equals("")) { Usernamefield.setText(UserData.readPref("username", this)); } if (!UserData.readPref("autorefresh", this).equals("")) { Button cmdRefresh = (Button) findViewById(R.id.cmdRefresh); TextView lblARefresh = (TextView) findViewById(R.id.lblAutorefresh); cmdRefresh.setVisibility(Button.INVISIBLE); lblARefresh.setVisibility(TextView.VISIBLE); Toast.makeText(this, "Automatisches Laden aktiviert!", Toast.LENGTH_SHORT).show(); autorefresh = 1; } if (UserData.readPref("ar_intervall", this).equals("")) { UserData.writePref("ar_intervall", "30000", this); } setTextSize(); setCookies(); final Button cmdSend = (Button) findViewById(R.id.cmdSend); if (requireLogin == 1 && loggedIn == 0) { cmdSend.setEnabled(false); cmdSend.setText("Zuerst einloggen!"); } cmdSend.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { InputMethodManager inputManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); send(); } }); final Button cmdRefresh = (Button) findViewById(R.id.cmdRefresh); cmdRefresh.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { getRequest(baseUrl + "index.php?page=ShoutboxEntryXMLList"); } }); final Button cmdMenu = (Button) findViewById(R.id.cmdMenu); cmdMenu.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { InputMethodManager inputManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); // openOptionsMenu(); Intent myIntent2 = new Intent(getApplicationContext(), Settings2.class); startActivityForResult(myIntent2, 0); } }); TextView lblVerlauf = (TextView) findViewById(R.id.lblVerlauf); lblVerlauf.setMovementMethod(LinkMovementMethod.getInstance()); lblVerlauf.setMovementMethod(new ScrollingMovementMethod()); }
From source file:kr.rrcoporation.rrfestival.festival.activity.FestivalDetailActivity.java
private void renderDetailView() { collapsingToolbarLayout.setTitle(detailInformation.getTitle()); eventDate.setText(detailInformation.getEventDate()); String addressText = detailInformation.getAddr1(); if (detailInformation.getAddr2() != null) { addressText += " " + detailInformation.getAddr2(); }/*from w ww .j a v a2s .c o m*/ address.setText(addressText); telephone.setText(Html.fromHtml(detailInformation.getTel())); program.setText(Html.fromHtml(detailInformation.getProgram())); subEvent.setText(Html.fromHtml(detailInformation.getSubEvent())); payType.setText(Html.fromHtml(detailInformation.getType())); program.setClickable(true); program.setMovementMethod(LinkMovementMethod.getInstance()); subEvent.setClickable(true); subEvent.setMovementMethod(LinkMovementMethod.getInstance()); String summary = ""; for (DetailSummary c : detailInformation.getSummaries()) { summary += c.getInfoname() + "<br/>"; summary += c.getInfotext() + "<br/>"; } summaryIntro.setText(Html.fromHtml(summary)); summaryIntro.setClickable(true); summaryIntro.setMovementMethod(LinkMovementMethod.getInstance()); imageAdapter = DetailImageAdapter.newInstance(FestivalDetailActivity.this, detailInformation.getImages()); imageViewPager.setAdapter(imageAdapter); imageViewPager.setCurrentItem(detailInformation.getImages().size() * 1000); }