package de.geeksfactory.opacclient.frontend;

import org.json.JSONException;

import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

import com.actionbarsherlock.view.MenuItem;

import de.geeksfactory.opacclient.R;

public class InfoActivity extends OpacActivity {

	private WebView wvInfo;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.info_activity);
		wvInfo = (WebView) findViewById(R.id.wvInfo);
		TextView tvErr = (TextView) findViewById(R.id.tvErr);
		wvInfo.loadData(getString(R.string.loading), "text/html", null);
		try {
			if (app.getLibrary().getData().getString("information") == null
					|| app.getLibrary().getData().getString("information")
							.equals("null")) {
				wvInfo.setVisibility(View.GONE);
				tvErr.setVisibility(View.VISIBLE);
				tvErr.setText(R.string.info_unsupported);
			} else {
				wvInfo.loadUrl(app.getLibrary().getData().getString("baseurl")
						+ app.getLibrary().getData().getString("information"));
			}
		} catch (JSONException e) {
			e.printStackTrace();
			wvInfo.setVisibility(View.GONE);
			tvErr.setVisibility(View.VISIBLE);
			tvErr.setText(R.string.info_error);
		}

		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			NavUtils.navigateUpFromSameTask(this);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}

@@ -714,12 +714,25 @@
 %0A%09%09%09
-if (
+String infoUrl = 
 app.
@@ -745,32 +745,38 @@
 rary().getData()
+%0A%09%09%09%09%09
 .getString(%22info
@@ -788,84 +788,43 @@
 on%22)
- == null%0A%09%09%09%09%09%7C%7C app.getLibrary().getData().getString(%22information%22)%0A%09%09%09%09%09%09%09
+;%0A%09%09%09if (infoUrl == null %7C%7C infoUrl
 .equ
@@ -960,16 +960,89 @@
 orted);%0A
+%09%09%09%7D else if (infoUrl.startsWith(%22http%22)) %7B%0A%09%09%09%09wvInfo.loadUrl(infoUrl);%0A
 %09%09%09%7D els
@@ -1124,59 +1124,15 @@
 %09%09+ 
-app.getLibrary().getData().getString(%22information%22)
+infoUrl
 );%0A%09

Allow absolute URLs for library information