List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderSS.java
protected void fetchDatabase(final DownloadItem di) { View alertView = View.inflate(this, R.layout.link_alert, null); TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText(/*from ww w. ja v a 2 s. com*/ 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.getTitle()) .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { mProgressDialog = ProgressDialog.show(DownloaderSS.this, getString(R.string.loading_please_wait), getString(R.string.loading_downloading)); new Thread() { public void run() { try { downloadDatabase(di); mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); String dbpath = Environment.getExternalStorageDirectory() .getAbsolutePath() + getString(R.string.default_dir); new AlertDialog.Builder(DownloaderSS.this) .setTitle(R.string.downloader_download_success) .setMessage( getString(R.string.downloader_download_success_message) + dbpath + di.getTitle() + ".db") .setPositiveButton(R.string.ok_text, null).create().show(); } }); } catch (final Exception e) { Log.e(TAG, "Error downloading", e); mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); new AlertDialog.Builder(DownloaderSS.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(); } }); } } }.start(); } }).setNegativeButton(getString(R.string.no_text), null).show(); }
From source file:com.prof.youtubeparser.example.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { android.support.v7.app.AlertDialog alertDialog = new android.support.v7.app.AlertDialog.Builder( MainActivity.this).create(); alertDialog.setTitle(R.string.app_name); alertDialog.setMessage(Html.fromHtml(MainActivity.this.getString(R.string.info_text) + " <a href='http://github.com/prof18/YoutubeParser'>GitHub.</a>" + MainActivity.this.getString(R.string.author))); alertDialog.setButton(android.support.v7.app.AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); }//from www . j a va 2 s.c o m }); alertDialog.show(); ((TextView) alertDialog.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } return super.onOptionsItemSelected(item); }
From source file:org.strongswan.android.ui.VpnProfileDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* the title is set when we load the profile, if any */ getSupportActionBar().setDisplayHomeAsUpEnabled(true); mDataSource = new VpnProfileDataSource(this); mDataSource.open();/*from ww w. j av a 2s.c om*/ setContentView(R.layout.profile_detail_view); mName = (MultiAutoCompleteTextView) findViewById(R.id.name); mNameWrap = (TextInputLayoutHelper) findViewById(R.id.name_wrap); mGateway = (EditText) findViewById(R.id.gateway); mGatewayWrap = (TextInputLayoutHelper) findViewById(R.id.gateway_wrap); mSelectVpnType = (Spinner) findViewById(R.id.vpn_type); mTncNotice = (RelativeLayout) findViewById(R.id.tnc_notice); mUsernamePassword = (ViewGroup) findViewById(R.id.username_password_group); mUsername = (EditText) findViewById(R.id.username); mUsernameWrap = (TextInputLayoutHelper) findViewById(R.id.username_wrap); mPassword = (EditText) findViewById(R.id.password); mUserCertificate = (ViewGroup) findViewById(R.id.user_certificate_group); mSelectUserCert = (RelativeLayout) findViewById(R.id.select_user_certificate); mSelectUserId = (Spinner) findViewById(R.id.select_user_id); mCheckAuto = (CheckBox) findViewById(R.id.ca_auto); mSelectCert = (RelativeLayout) findViewById(R.id.select_certificate); mShowAdvanced = (CheckBox) findViewById(R.id.show_advanced); mAdvancedSettings = (ViewGroup) findViewById(R.id.advanced_settings); mRemoteId = (MultiAutoCompleteTextView) findViewById(R.id.remote_id); mRemoteIdWrap = (TextInputLayoutHelper) findViewById(R.id.remote_id_wrap); mMTU = (EditText) findViewById(R.id.mtu); mMTUWrap = (TextInputLayoutHelper) findViewById(R.id.mtu_wrap); mPort = (EditText) findViewById(R.id.port); mPortWrap = (TextInputLayoutHelper) findViewById(R.id.port_wrap); mNATKeepalive = (EditText) findViewById(R.id.nat_keepalive); mNATKeepaliveWrap = (TextInputLayoutHelper) findViewById(R.id.nat_keepalive_wrap); mCertReq = (Switch) findViewById(R.id.cert_req); mIncludedSubnets = (EditText) findViewById(R.id.included_subnets); mIncludedSubnetsWrap = (TextInputLayoutHelper) findViewById(R.id.included_subnets_wrap); mExcludedSubnets = (EditText) findViewById(R.id.excluded_subnets); mExcludedSubnetsWrap = (TextInputLayoutHelper) findViewById(R.id.excluded_subnets_wrap); mBlockIPv4 = (CheckBox) findViewById(R.id.split_tunneling_v4); mBlockIPv6 = (CheckBox) findViewById(R.id.split_tunneling_v6); mSelectSelectedAppsHandling = (Spinner) findViewById(R.id.apps_handling); mSelectApps = (RelativeLayout) findViewById(R.id.select_applications); mIkeProposal = (EditText) findViewById(R.id.ike_proposal); mIkeProposalWrap = (TextInputLayoutHelper) findViewById(R.id.ike_proposal_wrap); mEspProposal = (EditText) findViewById(R.id.esp_proposal); mEspProposalWrap = (TextInputLayoutHelper) findViewById(R.id.esp_proposal_wrap); /* make the link clickable */ ((TextView) findViewById(R.id.proposal_intro)).setMovementMethod(LinkMovementMethod.getInstance()); final SpaceTokenizer spaceTokenizer = new SpaceTokenizer(); mName.setTokenizer(spaceTokenizer); mRemoteId.setTokenizer(spaceTokenizer); final ArrayAdapter<String> completeAdapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line); mName.setAdapter(completeAdapter); mRemoteId.setAdapter(completeAdapter); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { findViewById(R.id.apps).setVisibility(View.GONE); mSelectSelectedAppsHandling.setVisibility(View.GONE); mSelectApps.setVisibility(View.GONE); } mGateway.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) { completeAdapter.clear(); completeAdapter.add(mGateway.getText().toString()); if (TextUtils.isEmpty(mGateway.getText())) { mNameWrap.setHelperText(getString(R.string.profile_name_hint)); mRemoteIdWrap.setHelperText(getString(R.string.profile_remote_id_hint)); } else { mNameWrap.setHelperText( String.format(getString(R.string.profile_name_hint_gateway), mGateway.getText())); mRemoteIdWrap.setHelperText( String.format(getString(R.string.profile_remote_id_hint_gateway), mGateway.getText())); } } }); mSelectVpnType.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mVpnType = VpnType.values()[position]; updateCredentialView(); } @Override public void onNothingSelected(AdapterView<?> parent) { /* should not happen */ mVpnType = VpnType.IKEV2_EAP; updateCredentialView(); } }); ((TextView) mTncNotice.findViewById(android.R.id.text1)).setText(R.string.tnc_notice_title); ((TextView) mTncNotice.findViewById(android.R.id.text2)).setText(R.string.tnc_notice_subtitle); mTncNotice.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new TncNoticeDialog().show(VpnProfileDetailActivity.this.getSupportFragmentManager(), "TncNotice"); } }); mSelectUserCert.setOnClickListener(new SelectUserCertOnClickListener()); mSelectUserIdAdapter = new CertificateIdentitiesAdapter(this); mSelectUserId.setAdapter(mSelectUserIdAdapter); mSelectUserId.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (mUserCertEntry != null) { /* we don't store the subject DN as it is in the reverse order and the default anyway */ mSelectedUserId = position == 0 ? null : mSelectUserIdAdapter.getItem(position); } } @Override public void onNothingSelected(AdapterView<?> parent) { mSelectedUserId = null; } }); mCheckAuto.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { updateCertificateSelector(); } }); mSelectCert.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(VpnProfileDetailActivity.this, TrustedCertificatesActivity.class); intent.setAction(TrustedCertificatesActivity.SELECT_CERTIFICATE); startActivityForResult(intent, SELECT_TRUSTED_CERTIFICATE); } }); mShowAdvanced.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { updateAdvancedSettings(); } }); mSelectSelectedAppsHandling.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mSelectedAppsHandling = SelectedAppsHandling.values()[position]; updateAppsSelector(); } @Override public void onNothingSelected(AdapterView<?> parent) { /* should not happen */ mSelectedAppsHandling = SelectedAppsHandling.SELECTED_APPS_DISABLE; updateAppsSelector(); } }); mSelectApps.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(VpnProfileDetailActivity.this, SelectedApplicationsActivity.class); intent.putExtra(VpnProfileDataSource.KEY_SELECTED_APPS_LIST, new ArrayList<>(mSelectedApps)); startActivityForResult(intent, SELECT_APPLICATIONS); } }); mId = savedInstanceState == null ? null : savedInstanceState.getLong(VpnProfileDataSource.KEY_ID); if (mId == null) { Bundle extras = getIntent().getExtras(); mId = extras == null ? null : extras.getLong(VpnProfileDataSource.KEY_ID); } loadProfileData(savedInstanceState); updateCredentialView(); updateCertificateSelector(); updateAdvancedSettings(); updateAppsSelector(); }
From source file:org.navitproject.navit.Navit.java
private void showInfos() { SharedPreferences settings = getSharedPreferences(NAVIT_PREFS, MODE_PRIVATE); boolean firstStart = settings.getBoolean("firstStart", true); if (firstStart) { AlertDialog.Builder infobox = new AlertDialog.Builder(this); infobox.setTitle(getString(R.string.initial_info_box_title)); // TRANS infobox.setCancelable(false);// w w w .j a v a 2 s . c om final TextView message = new TextView(this); message.setFadingEdgeLength(20); message.setVerticalFadingEdgeEnabled(true); // message.setVerticalScrollBarEnabled(true); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); message.setLayoutParams(rlp); final SpannableString s = new SpannableString(getString(R.string.initial_info_box_message)); // TRANS Linkify.addLinks(s, Linkify.WEB_URLS); message.setText(s); message.setMovementMethod(LinkMovementMethod.getInstance()); infobox.setView(message); // TRANS infobox.setPositiveButton(getString(R.string.initial_info_box_OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Log.e("Navit", "Ok, user saw the infobox"); } }); // TRANS infobox.setNeutralButton(getString(R.string.initial_info_box_more_info), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Log.e("Navit", "user wants more info, show the website"); String url = "http://wiki.navit-project.org/index.php/Navit_on_Android"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); infobox.show(); SharedPreferences.Editor edit_settings = settings.edit(); edit_settings.putBoolean("firstStart", false); edit_settings.commit(); } }
From source file:com.appteam.nimbus.activity.homeActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*from w w w. j a v a 2 s . com*/ public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.navigation_to_profile) { // Handle the camera action Intent i = new Intent(homeActivity.this, Profile.class); startActivity(i); } else if (id == R.id.aboutus_nav) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format("%1$s", getString(R.string.app_name))); builder.setMessage(getResources().getText(R.string.aboutus_text)); builder.setPositiveButton("OK", null); builder.setIcon(R.mipmap.nimbus16); AlertDialog welcomeAlert = builder.create(); welcomeAlert.show(); ((TextView) welcomeAlert.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } else if (id == R.id.feedback_nav) { Intent intent = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + Uri.encode("appteam.nith@gmail.com") + "?subject=" + Uri.encode("Reporting A Bug/Feedback") + "&body=" + Uri.encode( "Hello, Appteam \nI want to report a bug/give feedback corresponding to the app Nimbus 2k16.\n.....\n\n-Your name"); Uri uri = Uri.parse(uriText); intent.setData(uri); startActivity(Intent.createChooser(intent, "Send Email")); } else if (id == R.id.opensourcelicenses_nav) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format("%1$s", getString(R.string.open_source_licenses))); builder.setMessage(getResources().getText(R.string.licenses_text)); builder.setPositiveButton("OK", null); //builder.setIcon(R.mipmap.nimbus_icon); AlertDialog welcomeAlert = builder.create(); welcomeAlert.show(); ((TextView) welcomeAlert.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } else if (id == R.id.contributors_nav) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format("%1$s", getString(R.string.contributors))); builder.setMessage(getResources().getText(R.string.contributors_text)); builder.setPositiveButton("OK", null); //builder.setIcon(R.mipmap.nimbus_icon); AlertDialog welcomeAlert = builder.create(); welcomeAlert.show(); ((TextView) welcomeAlert.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } else if (id == R.id.notifications) { startActivity(new Intent(homeActivity.this, ViewActivity.class)); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.ichi2.anki.StudyOptionsFragment.java
private void initAllContentViews() { if (mFragmented) { mStudyOptionsView.findViewById(R.id.studyoptions_gradient).setVisibility(View.VISIBLE); }//from w w w. j a v a 2 s . co m mDeckInfoLayout = mStudyOptionsView.findViewById(R.id.studyoptions_deckinformation); mTextDeckName = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_deck_name); mTextDeckDescription = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_deck_description); // make links clickable mTextDeckDescription.setMovementMethod(LinkMovementMethod.getInstance()); mButtonStart = (Button) mStudyOptionsView.findViewById(R.id.studyoptions_start); mTextCongratsMessage = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_congrats_message); // Code common to both fragmented and non-fragmented view mTextTodayNew = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_new); mTextTodayLrn = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_lrn); mTextTodayRev = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_rev); mTextNewTotal = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_total_new); mTextTotal = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_total); mTextETA = (TextView) mStudyOptionsView.findViewById(R.id.studyoptions_eta); mButtonStart.setOnClickListener(mButtonClickListener); }
From source file:com.ideascontest.navi.uask.MainQuestionAnswerAdapter.java
/** * OnBindViewHolder is called by the RecyclerView to display the data at the specified * position. In this method, we update the contents of the ViewHolder to display the correct * indices in the list for this particular position, using the "position" argument that is conveniently * passed into us.// w w w.j av a2 s. com * * @param holder The ViewHolder which should be updated to represent the contents of the * item at the given position in the data set. * @param position The position of the item within the adapter's data set. */ @Override public void onBindViewHolder(QuestionTopAnswerHolder holder, int position) { Log.d(TAG, "#" + position); QuestionTopAnswerHolder questionTopAnswerHolder = (QuestionTopAnswerHolder) holder; final Context context = questionTopAnswerHolder.v.getContext(); Log.d(TAG, "Category" + _category); switch (_category) { case 0: case 1: case 2: case 3: case 4: { if (position == 0) { /* String infoText = (String) questionTopAnswerHolder.basicInfoText.getText(); int count = infoText.split("\n").length; int upperLimit = (count > 5) ? MainAnswerAdapter.ordinalIndexOf(infoText, "\n", 5) : 140; if (infoText.length() > 140 || count > 5) { infoText = infoText.substring(0, upperLimit) + "... " + "view more"; SpannableString sText = new SpannableString(infoText); ClickableSpan myClickableSpan = new ClickableSpan() { @Override public void onClick(View v) { Log.d("MainCanvas Category", "clickable Span"); //finish(); } }; int spanLowLimit = upperLimit + 4; int spanHighLimit = upperLimit + 13; sText.setSpan(myClickableSpan, spanLowLimit, spanHighLimit, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sText.setSpan(new RelativeSizeSpan(0.75f), spanLowLimit, spanHighLimit, 0); sText.setSpan(new ForegroundColorSpan( questionTopAnswerHolder.v.getResources().getColor(R.color.primaryOrange)), spanLowLimit, spanHighLimit, 0); questionTopAnswerHolder.basicInfoText.setText(sText); questionTopAnswerHolder.basicInfoText.setMovementMethod(LinkMovementMethod.getInstance()); }*/ String infoText = (String) questionTopAnswerHolder.basicInfoText.getText(); int upperLimit = 150; if (infoText.length() > 150) { infoText = infoText.substring(0, upperLimit) + "... " + "view more"; SpannableString sText = new SpannableString(infoText); ClickableSpan myClickableSpan = new ClickableSpan() { @Override public void onClick(View v) { Log.d("Mainadapter Category", "clickable Span"); Intent intent = new Intent(context, ShowBasicInfo.class); intent.putExtra("category", _category); context.startActivity(intent);//finish(); } }; int spanLowLimit = upperLimit + 4; int spanHighLimit = upperLimit + 13; sText.setSpan(myClickableSpan, spanLowLimit, spanHighLimit, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sText.setSpan(new RelativeSizeSpan(0.75f), spanLowLimit, spanHighLimit, 0); sText.setSpan( new ForegroundColorSpan( questionTopAnswerHolder.v.getResources().getColor(R.color.primaryOrange)), spanLowLimit, spanHighLimit, 0); questionTopAnswerHolder.basicInfoText.setText(sText); questionTopAnswerHolder.basicInfoText.setMovementMethod(LinkMovementMethod.getInstance()); } } else { populateDynamicUiElements(questionTopAnswerHolder, (position - 1)); } } break; case 5: { if (position == 0) { questionTopAnswerHolder.basicInfoText.setText("List of all non-categorical questions"); questionTopAnswerHolder.basicInfoText.setGravity(Gravity.CENTER | Gravity.BOTTOM); questionTopAnswerHolder.headingText.setVisibility(View.INVISIBLE); } else { populateDynamicUiElements(questionTopAnswerHolder, (position - 1)); } } break; case 6: { if (position == 0) { questionTopAnswerHolder.basicInfoText.setText("List of all questions asked by you."); questionTopAnswerHolder.basicInfoText.setGravity(Gravity.CENTER | Gravity.BOTTOM); questionTopAnswerHolder.headingText.setVisibility(View.INVISIBLE); } else { populateDynamicUiElements(questionTopAnswerHolder, (position - 1)); } } break; case 7: { if (position == 0) { questionTopAnswerHolder.basicInfoText.setText("List of all questions answered by you."); questionTopAnswerHolder.basicInfoText.setGravity(Gravity.CENTER | Gravity.BOTTOM); questionTopAnswerHolder.headingText.setVisibility(View.INVISIBLE); } else { populateDynamicUiElements(questionTopAnswerHolder, (position - 1)); } } break; case 8: { if (position == 0) { questionTopAnswerHolder.basicInfoText.setText( "All the private questions asked by your faculty students. Visible only to fellow faculty students"); questionTopAnswerHolder.basicInfoText.setGravity(Gravity.CENTER | Gravity.BOTTOM); questionTopAnswerHolder.headingText.setVisibility(View.INVISIBLE); } else { populateDynamicUiElements(questionTopAnswerHolder, (position - 1)); } } break; default: { populateDynamicUiElements(questionTopAnswerHolder, position); } break; } }
From source file:de.blinkt.openvpn.fragments.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.about, container, false); TextView ver = (TextView) v.findViewById(R.id.version); String version;//from w w w. j av a 2 s . c om String name = "Openvpn"; try { PackageInfo packageinfo = getActivity().getPackageManager() .getPackageInfo(getActivity().getPackageName(), 0); version = packageinfo.versionName; name = getString(R.string.app); } catch (NameNotFoundException e) { version = "error fetching version"; } ver.setText(getString(R.string.version_info, name, version)); TextView paypal = (TextView) v.findViewById(R.id.donatestring); String donatetext = getActivity().getString(R.string.donatewithpaypal); Spanned htmltext = Html.fromHtml(donatetext); paypal.setText(htmltext); paypal.setMovementMethod(LinkMovementMethod.getInstance()); gmsTextView = (TextView) v.findViewById(R.id.donategms); /* recreating view without onCreate/onDestroy cycle */ // Disable GMS for now if (mService != null) initGooglePlayDonation(); TextView translation = (TextView) v.findViewById(R.id.translation); // Don't print a text for myself if (getString(R.string.translationby).contains("Arne Schwabe")) translation.setText(""); else translation.setText(R.string.translationby); WebView wv = (WebView) v.findViewById(R.id.webView); wv.loadUrl("file:///android_asset/full_licenses.html"); return v; }
From source file:me.acristoffers.tracker.activities.PackageListActivity.java
@SuppressLint("InflateParams") private void about() { final View about = View.inflate(this, R.layout.about, null); final PackageManager manager = getPackageManager(); final String packageName = getPackageName(); int versionCode = 0; String versionName = ""; try {//from w w w. j av a 2 s .c om final PackageInfo info = manager.getPackageInfo(packageName, 0); versionCode = info.versionCode; versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } final TextView version = (TextView) about.findViewById(R.id.version); if (version != null) { final String versionText = getString(R.string.version, versionName, versionCode); version.setText(versionText); } final TextView issues = (TextView) about.findViewById(R.id.issues); if (issues != null) { issues.setMovementMethod(LinkMovementMethod.getInstance()); } final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.app_name); builder.setView(about); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.setNeutralButton(R.string.rate_now, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { final String packageName = getPackageName(); final Uri uri = Uri.parse("market://details?id=" + packageName); startActivity(new Intent(Intent.ACTION_VIEW, uri)); dialogInterface.dismiss(); } }); final AlertDialog aboutDialog = builder.create(); aboutDialog.show(); }
From source file:org.liberty.android.fantastischmemo.downloader.DownloaderAnyMemo.java
@Override protected void fetchDatabase(final DownloadItem di) { final Thread downloadThread = new Thread() { @Override/*from ww w . j av a2s.c o m*/ public void run() { String filename = di.getExtras("filename"); try { downloadDatabase(di); filename = filename.replace(".zip", ".db"); String sdpath = AMEnv.DEFAULT_ROOT_PATH; 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(); }