If you think the Android project utexas-utilities listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.nasageek.utexasutilities.activities;
/*www.java2s.com*/import android.app.AlertDialog;
import android.app.Dialog;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.text.SpannableString;
import android.text.style.UnderlineSpan;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockDialogFragment;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.nasageek.utexasutilities.R;
publicclass AboutMeActivity extends SherlockFragmentActivity {
private ActionBar actionbar;
@Override
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.aboutme_layout);
actionbar = getSupportActionBar();
actionbar.setTitle("About");
actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionbar.setHomeButtonEnabled(true);
actionbar.setDisplayHomeAsUpEnabled(true);
// force the License Dialog link to be underlined so it looks "linky"
TextView licenseView = (TextView) findViewById(R.id.library_license_link);
SpannableString underlinedLicenseLink = new SpannableString(
getString(R.string.library_license_link));
underlinedLicenseLink.setSpan(new UnderlineSpan(), 0, underlinedLicenseLink.length(), 0);
licenseView.setText(underlinedLicenseLink);
licenseView.setOnClickListener(new OnClickListener() {
@Override
publicvoid onClick(View v) {
FragmentManager fm = getSupportFragmentManager();
LibraryLicenseDialog libraryLicenseDlg = new LibraryLicenseDialog();
libraryLicenseDlg.show(fm, "fragment_license");
}
});
// do the same thing with the Privacy Policy link
TextView policyView = (TextView) findViewById(R.id.privacy_policy_link);
SpannableString underlinedPolicyLink = new SpannableString(
getString(R.string.privacy_policy_link));
underlinedPolicyLink.setSpan(new UnderlineSpan(), 0, underlinedPolicyLink.length(), 0);
policyView.setText(underlinedPolicyLink);
policyView.setOnClickListener(new OnClickListener() {
@Override
publicvoid onClick(View v) {
FragmentManager fm = getSupportFragmentManager();
PrivacyPolicyDialog privacyPolicyDlg = new PrivacyPolicyDialog();
privacyPolicyDlg.show(fm, "fragment_privacy_policy");
}
});
TextView versionNumberView = (TextView) findViewById(R.id.version);
String versionName = "";
try {
versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (NameNotFoundException e) {
// of course UTilities is installed...
e.printStackTrace();
}
versionNumberView.setText(versionName);
}
@Override
publicboolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case android.R.id.home:
// app icon in action bar clicked; go home
super.onBackPressed();
break;
}
return false;
}
publicstaticclass PrivacyPolicyDialog extends SherlockDialogFragment {
public PrivacyPolicyDialog() {
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder build = new AlertDialog.Builder(getActivity());
build.setMessage(getString(R.string.privacy_policy)).setNeutralButton("Okay", null)
.setTitle("Privacy Policy");
return build.create();
}
}
publicstaticclass LibraryLicenseDialog extends SherlockDialogFragment {
public LibraryLicenseDialog() {
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder build = new AlertDialog.Builder(getActivity());
String licenseText = getString(R.string.licenses) + "\n\n" + "Legal Notices:" + "\n\n"
+ GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getActivity());
// licenseTextView = (TextView)
// view.findViewById(R.id.license_text);
// licenseTextView.setText(licenseText.getText()+"\n\n"+"Legal Notices:"+"\n\n"+
// GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(AboutMeActivity.this));
build.setMessage(licenseText).setNeutralButton("Okay", null)
.setTitle("Licenses and Legal Notices");
return build.create();
}
}
}