package jp.gr.java_conf.shiseissi.commonlib;

import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.graphics.Paint;
import android.hardware.Camera;
import android.os.AsyncTask;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;

import java.io.File;
import java.util.List;

/**
 *
 * @author shisei
 *
 */
@TargetApi(11)
public class APILevelWrapper11 extends APILevelWrapper {
    protected APILevelWrapper11() {
    }

    @Override
    public File getExternalFilesDir(Context context, String type) {
        return APILevelWrapper8.getExternalFilesDirImpl(context, type);
    }

    @Override
    public void setPluginsEnabled(WebSettings webSettings, boolean flag) {
        APILevelWrapper8.setPluginsEnabledImpl(webSettings, flag);
    }

    @Override
    public Object getActionBar(Activity activity) {
        return activity.getActionBar();
    }

    @Override
    public void setDisplayHomeAsUpEnabled_ActionBar(Object actionBar,
            boolean showHomeAsUp) {
        ((ActionBar) actionBar).setDisplayHomeAsUpEnabled(showHomeAsUp);
    }

    @Override
    public void setCustomView_ActionBar(Object actionBar, int resId) {
        ((ActionBar) actionBar).setCustomView(resId);
    }

    @SuppressWarnings("unchecked")
    @Override
    public <T extends View> T getCustomView_ActionBar(Object actionBar) {
        return (T) ((ActionBar) actionBar).getCustomView();
    }

    @Override
    public int getHeight_ActionBar(Object actionBar) {
        return ((ActionBar) actionBar).getHeight();
    }

    @Override
    public void show_ActionBar(Object actionBar) {
        ((ActionBar) actionBar).show();
    }

    @Override
    public void hide_ActionBar(Object actionBar) {
        ((ActionBar) actionBar).hide();
    }

    @Override
    public boolean isShowing_ActionBar(Object actionBar) {
        return ((ActionBar) actionBar).isShowing();
    }

    @Override
    public void setSystemUiVisibility(View view, int visibility) {
        view.setSystemUiVisibility(visibility);
    }

    @Override
    public <Params> AsyncTask<Params, ?, ?> executeOnSerialExecutor(AsyncTask<Params, ?, ?> task,
            Params... params) {
        return task.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, params);
    }

    @Override
    public <Params> AsyncTask<Params, ?, ?> executeOnThreadPoolExecutor(
            AsyncTask<Params, ?, ?> task, Params... params) {
        return task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
    }

    @Override
    public void setDisplayOrientation(Camera camera, int degrees) {
        camera.setDisplayOrientation(degrees);
    }

    @Override
    public void setPreviewSize(Camera.Parameters params,
            int width, int height) {
        params.setPreviewSize(width, height);
    }

    @Override
    public void getCameraInfo(int cameraId, CameraInfo cameraInfo) {
        APILevelWrapper9.getCameraInfoImpl(cameraId, cameraInfo);
    }

    @Override
    public List<Camera.Size> getSupportedPreviewSizes(Camera.Parameters params) {
        return params.getSupportedPreviewSizes();
    }

    @Override
    public List<Integer> getSupportedPreviewFormats(Camera.Parameters params) {
        return params.getSupportedPreviewFormats();
    }

    @SuppressWarnings("deprecation")
    @Override
    public void emulateShiftHeld(WebView webView) {
        webView.emulateShiftHeld();
    }

    @Override
    public void invalidateOptionsMenu(Activity activity) {
        activity.invalidateOptionsMenu();
    }

    @Override
    public void setLayerType(View view, int layerType, Paint paint) {
        view.setLayerType(layerType, paint);
    }
}
