Back to project page AppManager-for-Android.
The source code is released under:
Apache License
If you think the Android project AppManager-for-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.appmanager.android.app; /*from w w w .java 2 s.c o m*/ import android.os.Bundle; import android.text.Html; import android.text.util.Linkify; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; import com.appmanager.android.R; public class LicenseActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_license); createContent(); } @Override public boolean onOptionsItemSelected(final MenuItem menu) { if (menu.getItemId() == android.R.id.home) { finish(); return true; } return false; } private void createContent() { LayoutInflater inflater = LayoutInflater.from(this); LinearLayout content = (LinearLayout) findViewById(R.id.content); String[] softwareList = getResources().getStringArray(R.array.software_list); String[] licenseList = getResources().getStringArray(R.array.license_list); content.addView(createHtmlTextNoMargin(getString(R.string.msg_license))); content.addView(createItemsText(softwareList)); for (int i = 0; i < softwareList.length; i++) { content.addView(createDivider(inflater)); content.addView(createHeader(softwareList[i])); content.addView(createHtmlText(licenseList[i])); } } private TextView createHeader(final String name) { String s = "<big><b>" + name + "</b></big>"; return createHtmlText(s, 8); } private TextView createItemsText(final String... names) { StringBuilder s = new StringBuilder(); for (String name : names) { if (s.length() > 0) { s.append("<br>"); } s.append("?"); s.append(name); } return createHtmlText(s.toString(), 8); } private TextView createHtmlText(final String s) { return createHtmlText(s, 8); } private TextView createHtmlTextNoMargin(final String s) { return createHtmlText(s, 0); } private TextView createHtmlText(final String s, final int margin) { TextView text = new TextView(this); text.setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES); text.setText(Html.fromHtml(s)); text.setTextColor(getResources().getColor(R.color.text_license)); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); int marginPx = (0 < margin) ? (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, margin, getResources().getDisplayMetrics()) : 0; layoutParams.setMargins(0, marginPx, 0, marginPx); text.setLayoutParams(layoutParams); return text; } private View createDivider(final LayoutInflater inflater) { View view = inflater.inflate(R.layout.divider, null); int marginPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0.6f, getResources().getDisplayMetrics()); if (marginPx < 1) { marginPx = 1; } view.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, marginPx)); return view; } }