If you think the Android project Tacere 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
/*
* Copyright (c) 2014 Jonathan Nelson//www.java2s.com
* Released under the BSD license. For details see the COPYING file.
*/package org.ciasaboark.tacere.activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import org.ciasaboark.tacere.R;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
publicclass AboutLicenseActivity extends ActionBarActivity {
privatestaticfinal String TAG = "AboutLicenseActivity";
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about_activity_license);
// Show the Up button in the action bar.
setupActionBar();
WebView wv = (WebView) findViewById(R.id.webView1);
String htmlData = "";
try {
BufferedReader br = new BufferedReader(new InputStreamReader(getAssets().open("license.html")));
String line;
while ((line = br.readLine()) != null) {
htmlData += line;
}
} catch (FileNotFoundException e) {
Log.e(TAG, e.getMessage());
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
int colorInt = getResources().getColor(R.color.link_color);
String hexColor = String.format("#%06X", (0xFFFFFF & colorInt));
while (htmlData.contains("LINKCOLOR")) {
htmlData = htmlData.replace("LINKCOLOR", hexColor);
}
wv.loadData(htmlData, "text/html", "UTF8");
// All links should open in the default browser, not this WebView
wv.setWebViewClient(new WebViewClient() {
@Override
publicboolean shouldOverrideUrlLoading(WebView view, String url) {
view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
});
wv.setBackgroundColor(0x00000000);
wv.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
}
/**
* Set up the {@link android.app.ActionBar}.
*/privatevoid setupActionBar() {
try {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
} catch (NullPointerException e) {
Log.e(TAG, "unable to setup action bar");
}
}
@Override
publicboolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.about_activity_license, menu);
return true;
}
@Override
publicboolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
// http://developer.android.com/design/patterns/navigation.html#up-vs-back
//
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
}