package com.ikea.kompis.extendedcontent;

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import com.ikea.kompis.util.UiUtil;
import com.ikea.kompis.view.TitleView;
import com.ikea.publishingplatform.model.PublishingPlatformResponse;
import com.ikea.shared.util.L;
import java.util.HashMap;
import java.util.Map;

public class ECWebViewActivity extends ECStuffActivity
{
  public static final String EXTRA_TITLE = "title";
  public static final String EXTRA_URI = "extra_purchase_uri";
  private Context mContext;
  private boolean mHeaderLabelSet = false;
  private View mLoadingview;
  private String mTitle = "";
  String mWebUrl;
  private WebView mWebView = null;
  private WebViewClient myWebViewClient;

  private void hideLoadingView()
  {
    if ((this.mLoadingview != null) && (this.mLoadingview.getVisibility() == 0))
      this.mLoadingview.setVisibility(8);
  }

  private void initUI()
  {
    this.mWebView.getSettings().setJavaScriptEnabled(true);
    this.mWebView.getSettings().setSupportZoom(true);
    this.mWebView.getSettings().setBuiltInZoomControls(true);
    this.mWebView.getSettings().setUseWideViewPort(true);
    this.mWebView.getSettings().setLoadWithOverviewMode(true);
    if (this.mWebUrl != null)
    {
      HashMap localHashMap = new HashMap();
      localHashMap.put("connectionTimeout", "40000");
      this.mWebView.loadUrl(this.mWebUrl, localHashMap);
      return;
    }
    L.TOAST(this.mContext, "incorrect URL");
  }

  private static String parseDomain(String paramString)
  {
    try
    {
      Object localObject = Uri.parse(paramString).getHost().replace("www.", "");
      if (!TextUtils.isEmpty((CharSequence)localObject))
      {
        String str = Character.toUpperCase(((String)localObject).charAt(0)) + ((String)localObject).substring(1);
        localObject = str;
      }
      return localObject;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return null;
  }

  protected void closemWebView()
  {
    if (this.mWebView.canGoBack())
      this.mWebView.goBack();
    this.mWebView.onPause();
    finish();
    overridePendingTransition(2130968583, 2130968582);
  }

  protected void launchWebView(PublishingPlatformResponse paramPublishingPlatformResponse)
  {
    if (this.mWebView != null)
      this.mWebView.loadUrl(paramPublishingPlatformResponse.getUrl());
  }

  public void onBackPressed()
  {
    if (this.mWebView.canGoBack())
    {
      this.mWebView.goBack();
      return;
    }
    this.mWebView.onPause();
    super.onBackPressed();
  }

  @SuppressLint({"SetJavaScriptEnabled"})
  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    UiUtil.applyLocaleString(this, false);
    setContentView(2130903040);
    setResult(0);
    getActionBar().setCustomView(2130903077);
    ImageView localImageView = (ImageView)getActionBar().getCustomView().findViewById(2131624017);
    TitleView localTitleView = (TitleView)getActionBar().getCustomView().findViewById(2131623960);
    this.mContext = this;
    L.D(this, " purchase URI is " + getIntent().getStringExtra("extra_purchase_uri"));
    this.mWebUrl = getIntent().getStringExtra("extra_purchase_uri");
    this.mLoadingview = findViewById(2131623955);
    localImageView.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        ECWebViewActivity.this.closemWebView();
      }
    });
    if (getIntent().hasExtra("title"))
    {
      this.mHeaderLabelSet = true;
      this.mTitle = getIntent().getStringExtra("title");
      localTitleView.setText(this.mTitle);
    }
    if ((!getIntent().hasExtra("load_eccontent")) && (UiUtil.isTablet(this)))
      getActionBar().getCustomView().findViewById(2131624014).setVisibility(8);
    this.myWebViewClient = new MyWebViewClient();
    this.mWebView = ((WebView)findViewById(2131623938));
    this.mWebView.setWebViewClient(this.myWebViewClient);
    this.mWebView.setWebChromeClient(new WebChromeClient());
    if (paramBundle == null)
    {
      initUI();
      return;
    }
    this.mWebView.restoreState(paramBundle);
  }

  protected void onPause()
  {
    this.mWebView.onPause();
    super.onPause();
  }

  protected void onResume()
  {
    super.onResume();
    this.mWebView.onResume();
  }

  protected void onSaveInstanceState(Bundle paramBundle)
  {
    super.onSaveInstanceState(paramBundle);
    this.mWebView.saveState(paramBundle);
  }

  protected void setOrientation()
  {
  }

  class MyWebViewClient extends WebViewClient
  {
    MyWebViewClient()
    {
    }

    public void onPageFinished(WebView paramWebView, String paramString)
    {
      if (!ECWebViewActivity.this.mHeaderLabelSet)
      {
        String str = ECWebViewActivity.parseDomain(paramString);
        if (str != null)
          ECWebViewActivity.this.setTitle(str);
      }
      ECWebViewActivity.this.hideLoadingView();
    }

    public void onReceivedError(WebView paramWebView, int paramInt, String paramString1, String paramString2)
    {
      super.onReceivedError(paramWebView, paramInt, paramString1, paramString2);
      L.E(this, "onReceivedError error code " + paramInt + "  desc " + paramString1 + " failing url " + paramString2);
      L.TOAST(ECWebViewActivity.this.mContext, "Error while loading page " + paramString1);
      ECWebViewActivity.this.hideLoadingView();
    }

    public void onReceivedSslError(WebView paramWebView, SslErrorHandler paramSslErrorHandler, SslError paramSslError)
    {
      paramSslErrorHandler.cancel();
      L.E(this, "onReceivedSslError");
    }

    public boolean shouldOverrideUrlLoading(WebView paramWebView, String paramString)
    {
      return false;
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.extendedcontent.ECWebViewActivity
 * JD-Core Version:    0.6.2
 */