package jp.gr.java_conf.shiseissi.commonlib;

import android.annotation.TargetApi;
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(9)
public class APILevelWrapper9 extends APILevelWrapper {
    protected APILevelWrapper9() {
    }

    @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 null;
    }

    @Override
    public void setDisplayHomeAsUpEnabled_ActionBar(Object actionBar,
            boolean showHomeAsUp) {
        // 空実装
    }

    @Override
    public void setCustomView_ActionBar(Object actionBar, int resId) {
        // 空実装
    }

    @Override
    public <T extends View> T getCustomView_ActionBar(Object actionBar) {
        // 空実装
        return null;
    }

    @Override
    public int getHeight_ActionBar(Object actionBar) {
        // 空実装
        return 0;
    }

    @Override
    public void show_ActionBar(Object actionBar) {
        // 空実装
    }

    @Override
    public void hide_ActionBar(Object actionBar) {
        // 空実装
    }

    @Override
    public boolean isShowing_ActionBar(Object actionBar) {
        // 空実装
        return false;
    }

    @Override
    public void setSystemUiVisibility(View view, int visibility) {
        // 空実装
    }

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

    @Override
    public <Params> AsyncTask<Params, ?, ?> executeOnThreadPoolExecutor(
            AsyncTask<Params, ?, ?> task, Params... params) {
        return task.execute(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) {
        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) {
        // 空実装
    }

    @Override
    public void setLayerType(View view, int layerType, Paint paint) {
        // 空実装
    }

    static void getCameraInfoImpl(int cameraId, CameraInfo cameraInfo) {
        android.hardware.Camera.CameraInfo temp = new android.hardware.Camera.CameraInfo();
        Camera.getCameraInfo(cameraId, temp);
        cameraInfo.facing = temp.facing;
        cameraInfo.orientation = temp.orientation;
    }
}
