/*
 * Copyright 2012 Artur Dryomov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package ru.ming13.gambit.ui.activity;


import android.content.ContentResolver;
import android.os.Bundle;
import android.webkit.WebView;
import com.actionbarsherlock.app.SherlockActivity;
import ru.ming13.gambit.R;


public class LicensesActivity extends SherlockActivity
{
	private static final String SCHEME = ContentResolver.SCHEME_FILE;
	private static final String AUTHORITY = "android_asset";
	private static final String PATH = "licenses.html";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_licenses);

		setUpLicenses();
	}

	private void setUpLicenses() {
		getWebView().loadUrl(buildLicensesUri());
	}

	private WebView getWebView() {
		return (WebView) findViewById(R.id.licenses_webview);
	}

	private String buildLicensesUri() {
		return String.format("%s:///%s/%s", SCHEME, AUTHORITY, PATH);
	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);

		getWebView().saveState(outState);
	}

	@Override
	protected void onRestoreInstanceState(Bundle savedInstanceState) {
		super.onRestoreInstanceState(savedInstanceState);

		getWebView().restoreState(savedInstanceState);
	}
}

@@ -1212,16 +1212,60 @@
 enses();
+%0A%0A%09%09restoreWebViewState(savedInstanceState);
 %0A%09%7D%0A%0A%09pr
@@ -1543,48 +1543,35 @@
 %7D%0A%0A%09
-@Override%0A%09protec
+priva
 te
-d
  void 
-onSaveInstance
+restoreWebView
 Stat
@@ -1579,19 +1579,21 @@
 (Bundle 
-out
+saved
 State) %7B
@@ -1599,46 +1599,35 @@
 %7B%0A%09%09
-super.onSaveInstanceState(outState);%0A%0A
+if (savedState != null) %7B%0A%09
 %09%09ge
@@ -1641,29 +1641,34 @@
 w().
-sav
+restor
 eState(
-out
+saved
 State);%0A
 %09%7D%0A%0A
@@ -1659,24 +1659,28 @@
 avedState);%0A
+%09%09%7D%0A
 %09%7D%0A%0A%09@Overri
@@ -1700,22 +1700,19 @@
  void on
-Restor
+Sav
 eInstanc
@@ -1729,116 +1729,71 @@
 dle 
-savedInstanceState) %7B%0A%09%09super.onRestoreInstanceState(savedInstanceState);%0A%0A%09%09getWebView().restoreState(s
+outState) %7B%0A%09%09getWebView().saveState(outState);%0A%0A%09%09super.onS
 ave
-d
 Inst
@@ -1797,20 +1797,29 @@
 nstanceState
+(outState
 );%0A%09%7D%0A%7D%0A

Change licenses web view saving-restoring state flow.