import android.util.Log;
import android.view.WindowManager;
+import net.osdn.gokigen.a01d.camera.olympus.IOlympusDisplayInjector;
import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
import net.osdn.gokigen.a01d.camera.olympus.cameraproperty.OlyCameraPropertyListFragment;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.OlympusInterfaceProvider;
public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver, IChangeScene {
private final String TAG = toString();
private IOlympusInterfaceProvider interfaceProvider = null;
+ private IOlympusDisplayInjector interfaceInjector = null;
private IStatusViewDrawer statusViewDrawer = null;
private PreferenceFragment preferenceFragment = null;
/**
* クラスの初期化
*/
- private void initializeClass() {
- try {
- interfaceProvider = new OlympusInterfaceProvider(this, this);
- } catch (Exception e) {
+ private void initializeClass()
+ {
+ try
+ {
+ OlympusInterfaceProvider provider = new OlympusInterfaceProvider(this, this);
+ interfaceProvider = provider;
+ interfaceInjector = provider;
+ } catch (Exception e)
+ {
e.printStackTrace();
}
}
/**
* フラグメントの初期化
*/
- private void initializeFragment() {
+ private void initializeFragment()
+ {
LiveViewFragment fragment = new LiveViewFragment();
statusViewDrawer = fragment;
- fragment.prepare(this, interfaceProvider.getLiveViewControl());
+ fragment.prepare(this, interfaceProvider, interfaceInjector);
fragment.setRetainInstance(true);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment1, fragment);
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus;
+
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+/**
+ *
+ *
+ */
+public interface IOlympusDisplayInjector
+{
+ void injectOlympusDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator);
+
+}
package net.osdn.gokigen.a01d.camera.olympus;
+import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraHardwareStatus;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraRunMode;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ILiveViewControl;
IOlyCameraPropertyProvider getCameraPropertyProvider();
ICameraRunMode getCameraRunMode();
ILiveViewControl getLiveViewControl();
+ IFocusingControl getFocusingControl();
}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.operation;
+
+import android.view.MotionEvent;
+
+/**
+ *
+ *
+ */
+public interface IFocusingControl
+{
+ boolean driveAutoFocus(MotionEvent motionEvent);
+ void unlockAutoFocus();
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.operation.takepicture;
+
+import android.graphics.PointF;
+import android.graphics.RectF;
+
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
+import jp.co.olympus.camerakit.OLYCameraKitException;
+
+
+/**
+ * オートフォーカス制御クラス
+ *
+ * 1. setAutoFocusFrameDisplay() で AFフレームの表示クラスを設定
+ * 2. lockAutoFocus() で AF-Lockを実行
+ * 3. unlockAutoFocus() で AF-Unlock を実行
+ *
+ */
+public class AutoFocusControl implements OLYCamera.TakePictureCallback
+{
+ private final OLYCamera camera;
+ private final IIndicatorControl indicator;
+
+ private IAutoFocusFrameDisplay frameDisplayer = null;
+ private RectF focusFrameRect = null;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ public AutoFocusControl(OLYCamera camera, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ {
+ this.camera = camera;
+ this.frameDisplayer = frameDisplayer;
+ this.indicator = indicator;
+ }
+
+ /**
+ * オートフォーカスを駆動させ、ロックする
+ *
+ * @param point ターゲットAF点
+ *
+ */
+ public boolean lockAutoFocus(PointF point)
+ {
+ if (camera.isTakingPicture() || camera.isRecordingVideo())
+ {
+ // 撮影中の場合にはフォーカスロックはやらない。
+ return (false);
+ }
+
+ RectF preFocusFrameRect = getPreFocusFrameRect(point);
+ showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Running, 0.0);
+
+ try
+ {
+ // Set auto-focus point.
+ camera.setAutoFocusPoint(point);
+
+ // Lock auto-focus.
+ focusFrameRect = preFocusFrameRect;
+ camera.lockAutoFocus(this);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ // Lock failed.
+ try
+ {
+ camera.clearAutoFocusPoint();
+ camera.unlockAutoFocus();
+ showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Failed, 1.0);
+ }
+ catch (Exception ee)
+ {
+ ee.printStackTrace();
+ }
+ return (false);
+ }
+ return (true);
+ }
+
+ /**
+ * AF-Lを解除する
+ *
+ */
+ public void unlockAutoFocus()
+ {
+ if (camera.isTakingPicture() || camera.isRecordingVideo())
+ {
+ // 撮影中の場合には、フォーカスロック解除はやらない
+ return;
+ }
+
+ // Unlock auto-focus.
+ try
+ {
+ camera.unlockAutoFocus();
+ camera.clearAutoFocusPoint();
+ hideFocusFrame();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onProgress(OLYCamera olyCamera, OLYCamera.TakingProgress takingProgress, OLYCameraAutoFocusResult olyCameraAutoFocusResult)
+ {
+ if (takingProgress == OLYCamera.TakingProgress.EndFocusing)
+ {
+ if (olyCameraAutoFocusResult.getResult().equals("ok") && olyCameraAutoFocusResult.getRect() != null)
+ {
+ // Lock succeed.
+ RectF postFocusFrameRect = olyCameraAutoFocusResult.getRect();
+ showFocusFrame(postFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Focused, 0.0);
+
+ }
+ else if (olyCameraAutoFocusResult.getResult().equals("none"))
+ {
+ // Could not lock.
+ try
+ {
+ camera.clearAutoFocusPoint();
+ camera.unlockAutoFocus();
+ }
+ catch (OLYCameraKitException ee)
+ {
+ ee.printStackTrace();
+ }
+ hideFocusFrame();
+ }
+ else
+ {
+ // Lock failed.
+ try
+ {
+ camera.clearAutoFocusPoint();
+ camera.unlockAutoFocus();
+ }
+ catch (OLYCameraKitException ee)
+ {
+ ee.printStackTrace();
+ }
+ showFocusFrame(focusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Failed, 1.0);
+ }
+ }
+ }
+
+ @Override
+ public void onCompleted()
+ {
+ // フォーカスロック成功、なにもしない
+ }
+
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ // フォーカスロック失敗 : 通知される
+ e.printStackTrace();
+ try
+ {
+ camera.clearAutoFocusPoint();
+ camera.unlockAutoFocus();
+ hideFocusFrame();
+ }
+ catch (Exception ee)
+ {
+ ee.printStackTrace();
+ }
+ showFocusFrame(focusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Errored, 1.0);
+ }
+
+ private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
+ {
+ if (frameDisplayer != null)
+ {
+ frameDisplayer.showFocusFrame(rect, status, duration);
+ }
+ indicator.onAfLockUpdate(IAutoFocusFrameDisplay.FocusFrameStatus.Focused == status);
+ }
+
+ private void hideFocusFrame()
+ {
+ if (frameDisplayer != null)
+ {
+ frameDisplayer.hideFocusFrame();
+ }
+ indicator.onAfLockUpdate(false);
+ }
+
+ private RectF getPreFocusFrameRect(PointF point)
+ {
+ float imageWidth = 1.0f;
+ float imageHeight = 1.0f;
+ if (frameDisplayer != null)
+ {
+ imageWidth = frameDisplayer.getContentSizeWidth();
+ imageHeight = frameDisplayer.getContentSizeHeight();
+ }
+ // Display a provisional focus frame at the touched point.
+ float focusWidth = 0.125f; // 0.125 is rough estimate.
+ float focusHeight = 0.125f;
+ if (imageWidth > imageHeight)
+ {
+ focusHeight *= (imageWidth / imageHeight);
+ }
+ else
+ {
+ focusHeight *= (imageHeight / imageWidth);
+ }
+ return (new RectF(point.x - focusWidth / 2.0f, point.y - focusHeight / 2.0f,
+ point.x + focusWidth / 2.0f, point.y + focusHeight / 2.0f));
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.operation.takepicture;
+import android.graphics.PointF;
+import android.util.Log;
+
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
+
+/**
+ * オートブラケッティング実行クラス
+ *
+ *
+ * Created by MRSa on 2016/06/18.
+ */
+public class BracketingShotControl implements OLYCamera.TakePictureCallback
+{
+ private final String TAG = toString();
+
+ private static final int BRACKETING_INTERVAL_MILLISECOND = 300; // 撮影待ち時間(ms)
+ private static final int BRACKETING_PROPERTY_VALUE_SET_RETRY = 10;
+
+ private static final int BRACKET_NONE = 0; // 通常のショット
+ private static final int BRACKET_EXPREV = 1; // 露出補正
+ private static final int BRACKET_APERTURE = 2; // 絞り
+ private static final int BRACKET_ISO = 3; // ISO
+ private static final int BRACKET_SHUTTER = 4; // シャッター
+ private static final int BRACKET_WB = 5; // ホワイトバランス
+ private static final int BRACKET_COLOR_TONE = 6; // カラートーン
+
+ private final OLYCamera camera;
+ private final IAutoFocusFrameDisplay autoFocusFrame;
+ private final IIndicatorControl indicator;
+ private boolean isShootingWait = false;
+ private boolean isBracketingAction = false;
+ private int retryUpdateBracketingStatus = 0;
+ private int waitSeconds = 0; // 撮影待ち時間
+
+ private int bracketCount = 0;
+ private String targetPropertyName = null;
+ private String originalProperty = null;
+ private int originalPropertyIndex = -1;
+ private List<String> propertyValueList = null;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ public BracketingShotControl(OLYCamera camera, IAutoFocusFrameDisplay autoFocusFrame, IIndicatorControl indicator)
+ {
+ this.camera = camera;
+ this.autoFocusFrame = autoFocusFrame;
+ this.indicator = indicator;
+ }
+
+ /**
+ * ブラケッティング対象のプロパティの現在設定値と、その選択肢を記憶する
+ *
+ * @param name ブラケッティング対象の名前
+ * @return ブラケッティングの現在設定値
+ */
+ private int prepareBracketProperty(String name)
+ {
+ try
+ {
+ targetPropertyName = name;
+ if (name.length() > 0)
+ {
+ originalProperty = camera.getCameraPropertyValue(name);
+ propertyValueList = camera.getCameraPropertyValueList(name);
+ if (bracketCount < 0)
+ {
+ bracketCount = propertyValueList.size();
+ }
+ return (propertyValueList.indexOf(originalProperty));
+ }
+ else
+ {
+ originalProperty = null;
+ propertyValueList = null;
+ }
+ }
+ catch (Exception e)
+ {
+ originalProperty = null;
+ propertyValueList = null;
+ e.printStackTrace();
+ System.gc();
+ }
+ return (-1);
+ }
+
+
+ /**
+ * ブラケッティング対象のプロパティを特定する
+ *
+ * @param isBracketing プロパティ
+ * @return true : 対象の特定完了 / false : 対象の特定失敗
+ */
+ private boolean decideBracketProperty(int isBracketing)
+ {
+/*
+ switch (isBracketing)
+ {
+ case BRACKET_EXPREV:
+ // 露出ブラケット
+ targetPropertyName = IOlyCameraProperty.EXPOSURE_COMPENSATION;
+ break;
+
+ case BRACKET_APERTURE:
+ // 絞り値設定
+ targetPropertyName = IOlyCameraProperty.APERTURE;
+ break;
+
+ case BRACKET_ISO:
+ // ISO
+ targetPropertyName = IOlyCameraProperty.ISO_SENSITIVITY;
+ break;
+
+ case BRACKET_SHUTTER:
+ // シャッターブラケット
+ targetPropertyName = IOlyCameraProperty.SHUTTER_SPEED;
+ break;
+
+ case BRACKET_WB:
+ // ホワイトバランスブラケット
+ targetPropertyName = IOlyCameraProperty.WB_MODE;
+ bracketCount = -1;
+ break;
+
+ case BRACKET_COLOR_TONE:
+ // ピクチャーモードブラケット
+ targetPropertyName = IOlyCameraProperty.COLOR_TONE;
+ bracketCount = -1;
+ break;
+
+ case BRACKET_NONE:
+ // パラメータは変更しないパターン...
+ targetPropertyName = "";
+ break;
+
+ default:
+ // 何もしない
+ return (false);
+ }
+*/
+ targetPropertyName = "";
+ originalPropertyIndex = prepareBracketProperty(targetPropertyName);
+ return (true);
+ }
+
+
+ /**
+ * 写真撮影(ブラケッティング撮影)を開始する
+ * bracketingStyle : ブラケッティングスタイル
+ * bracketingCount : 撮影枚数
+ * durationSeconds : 撮影間隔(単位:秒)
+ */
+ public void startShootBracketing(int bracketingStyle, int bracketingCount, int durationSeconds)
+ {
+ if ((camera.isTakingPicture())||(camera.isRecordingVideo())||(isBracketingAction))
+ {
+ // スチル or ムービー撮影中、ブラケッティング撮影中なら、何もしない
+ return;
+ }
+
+ // ブラケッティング撮影の準備
+ bracketCount = bracketingCount;
+ if (!decideBracketProperty(bracketingStyle))
+ {
+ // ブラケッティング指定ではないので、何もせずに終了する
+ return;
+ }
+
+ // 撮影間隔 (単位:秒)
+ waitSeconds = durationSeconds;
+
+ // ブラケッティング撮影開始! (別スレッドでブラケッティング撮影を開始する)
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ executor.submit(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ isBracketingAction = true;
+ indicator.onBracketingStatusUpdate("INT");
+ try
+ {
+ startBracket();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ isBracketingAction = false;
+ indicator.onBracketingStatusUpdate("");
+ }
+ });
+ }
+
+ /**
+ * ブラケッティング撮影を開始する
+ * (これは別スレッドで処理する)
+ *
+ * 一番小さい選択肢(インデックス)から設定された撮影枚数分、
+ * 徐々に選択肢をずらして撮影する。
+ *
+ */
+ private void startBracket()
+ {
+ int startIndex = originalPropertyIndex - (bracketCount / 2);
+ if (propertyValueList != null)
+ {
+ if ((startIndex + bracketCount) > propertyValueList.size())
+ {
+ startIndex = propertyValueList.size() - bracketCount;
+ }
+ }
+ if (startIndex < 0)
+ {
+ startIndex = 0;
+ }
+
+ PointF afPoint = camera.getActualAutoFocusPoint();
+ for (int index = 0; index < bracketCount; index++)
+ {
+ // 撮影条件を更新する
+ updateBracketingStatus(index, startIndex);
+ startIndex++;
+
+ try
+ {
+ // AFポイントを設定する
+ if (afPoint != null)
+ {
+ camera.setAutoFocusPoint(afPoint);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ if (bracketCount == 1)
+ {
+ // 1枚しか撮影しない時は、撮影前にウェイトをかける
+ waitSeconds(waitSeconds);
+ }
+
+ try
+ {
+ // 写真を撮影する
+ camera.takePicture(new HashMap<String, Object>(), this);
+ isShootingWait = true;
+ while (isShootingWait)
+ {
+ // ここで撮影状態が整うまで少し待つ
+ Thread.sleep(BRACKETING_INTERVAL_MILLISECOND);
+ updateShootingWaitStatus();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ // 指定された時間待機、ただし、最後の撮影が終わったあとには待たないようにする。
+ if ((index + 1) < bracketCount)
+ {
+ waitSeconds(waitSeconds);
+ }
+ }
+ try
+ {
+ // 変更したプロパティ値を元の値に戻す...ちょっと待ってから
+ Thread.sleep(BRACKETING_INTERVAL_MILLISECOND);
+ if (originalProperty != null)
+ {
+ camera.setCameraPropertyValue(targetPropertyName, originalProperty);
+ }
+
+ // とにかくAF枠を消す。
+ camera.clearAutoFocusPoint();
+ autoFocusFrame.hideFocusFrame();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 指定された時間待機する
+ *
+ * @param seconds 待機秒数
+ */
+ private void waitSeconds(int seconds)
+ {
+ for (int count = seconds; count > 0; count--)
+ {
+ // 待ち時間(単位:秒)
+ try
+ {
+ // BKT表示(撮影枚数表示と待ち時間)を変える
+ indicator.onBracketingStatusUpdate("WAIT " + count + "sec.");
+ Thread.sleep(1000);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ indicator.onBracketingStatusUpdate("");
+ }
+
+ /**
+ * ブラケッティング撮影の状態を更新する
+ *
+ * @param index 撮影が終了したカウント(0始まり)
+ */
+ private void updateBracketingStatus(int index, int currentIndex)
+ {
+ Log.v(TAG, "updateBracketingStatus() : " + index + "(" + currentIndex + ")");
+
+ // カメラのプロパティ設定を変える
+ try
+ {
+ if (propertyValueList != null)
+ {
+ Thread.sleep(BRACKETING_INTERVAL_MILLISECOND);
+ camera.setCameraPropertyValue(targetPropertyName, propertyValueList.get(currentIndex));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+
+ // 頭に来たので、再度呼ぶ (リトライオーバーするまで)
+ if (retryUpdateBracketingStatus < BRACKETING_PROPERTY_VALUE_SET_RETRY)
+ {
+ retryUpdateBracketingStatus++;
+ updateBracketingStatus(index, currentIndex);
+ }
+ }
+ retryUpdateBracketingStatus = 0;
+
+ // 撮影枚数表示を変える
+ indicator.onBracketingStatusUpdate("INT " + (index + 1) + "/" + bracketCount);
+ }
+
+ /**
+ * カメラの状態を取得し、撮影可能か確認する。
+ * (trueならまだ撮影処理中、falseなら撮影可能)
+ */
+ private void updateShootingWaitStatus()
+ {
+ boolean isBusy = false;
+ try
+ {
+ isBusy = ((camera.isTakingPicture())||(camera.isMediaBusy())||(camera.isRecordingVideo()));
+
+ // ちょっと待ち時間をとりたい...
+ String messageToShow = "getShootingBusyStatus() : " + String.valueOf(isBusy);
+ Log.v(TAG, messageToShow);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ isShootingWait = isBusy;
+ }
+
+ /**
+ * OLYCamera.TakePictureCallback の実装
+ *
+ *
+ */
+ @Override
+ public void onProgress(OLYCamera olyCamera, OLYCamera.TakingProgress takingProgress, OLYCameraAutoFocusResult olyCameraAutoFocusResult)
+ {
+ // 特に何もしないでおこう
+ }
+
+ /**
+ * OLYCamera.TakePictureCallback の実装
+ *
+ */
+ @Override
+ public void onCompleted()
+ {
+ // 撮影待ち状態の更新
+ updateShootingWaitStatus();
+ }
+
+ /**
+ * OLYCamera.TakePictureCallback の実装
+ *
+ * @param e 例外情報
+ */
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ e.printStackTrace();
+
+ // 撮影待ち状態の更新
+ updateShootingWaitStatus();
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.operation.takepicture;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.util.Log;
+
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+import java.util.HashMap;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraKitException;
+
+
+/**
+ * ビデオ撮影の開始・終了制御クラス。
+ *
+ */
+public class MovieRecordingControl implements OLYCamera.CompletedCallback
+{
+ private final String TAG = toString();
+ private final Context context;
+ private final OLYCamera camera;
+ private final IIndicatorControl indicator;
+ private IIndicatorControl.shootingStatus isRecordingStart = IIndicatorControl.shootingStatus.Unknown;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ public MovieRecordingControl(Context context, OLYCamera camera, IIndicatorControl indicator)
+ {
+ this.context = context;
+ this.camera = camera;
+ this.indicator = indicator;
+ }
+
+ /**
+ * 動画撮影の開始と終了
+ *
+ */
+ public void movieControl()
+ {
+ try
+ {
+ Log.v(TAG, "MovieRecordingControl::movieControl()");
+ if (camera.isTakingPicture())
+ {
+ // スチル撮影中の場合は、何もしない(モード異常なので)
+ Log.v(TAG, "NOW TAKING PICTURE(STILL) : COMMAND IGNORED");
+ return;
+ }
+
+ if (!camera.isRecordingVideo())
+ {
+ // ムービー撮影の開始指示
+ camera.startRecordingVideo(new HashMap<String, Object>(), this);
+ isRecordingStart = IIndicatorControl.shootingStatus.Starting;
+ }
+ else
+ {
+ // ムービー撮影の終了指示
+ camera.stopRecordingVideo(this);
+ isRecordingStart = IIndicatorControl.shootingStatus.Stopping;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 処理完了
+ *
+ */
+ @Override
+ public void onCompleted()
+ {
+ try
+ {
+ Log.v(TAG, "MovieRecordingControl::onCompleted()");
+ // 撮影終了をバイブレータで知らせる
+ //statusDrawer.vibrate(IShowInformation.VIBRATE_PATTERN_SIMPLE_MIDDLE);
+ indicator.onMovieStatusUpdate(isRecordingStart);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * エラー発生
+ *
+ * @param e 例外情報
+ */
+ @Override
+ public void onErrorOccurred(OLYCameraKitException e)
+ {
+ // 撮影失敗をバイブレータで知らせる
+ //statusDrawer.vibrate(IShowInformation.VIBRATE_PATTERN_SIMPLE_SHORT);
+ {
+ //// 撮影失敗の表示をToastで行う
+ //Toast.makeText(context, R.string.video_failure, Toast.LENGTH_SHORT).show();
+ Log.v(TAG, "MovieControl::onErrorOccurred()");
+ isRecordingStart = IIndicatorControl.shootingStatus.Unknown;
+ indicator.onMovieStatusUpdate(isRecordingStart);
+ }
+ e.printStackTrace();
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.operation.takepicture;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.RectF;
+import android.util.Log;
+
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
+
+
+/**
+ * 連続撮影用のクラス
+ *
+ */
+public class SequentialShotControl implements OLYCamera.TakePictureCallback
+{
+ private final String TAG = toString();
+ private final Context context;
+ private final OLYCamera camera;
+ private final IIndicatorControl indicator;
+ private IAutoFocusFrameDisplay frameDisplayer = null;
+
+ private IIndicatorControl.shootingStatus currentStatus = IIndicatorControl.shootingStatus.Unknown;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ public SequentialShotControl(Context context, OLYCamera camera, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ {
+ this.context = context;
+ this.camera = camera;
+ this.frameDisplayer = frameDisplayer;
+ this.indicator = indicator;
+ }
+
+ /**
+ * 撮影の開始と終了
+ *
+ */
+ public void shotControl()
+ {
+ if (camera.isRecordingVideo())
+ {
+ // ビデオ撮影中の場合は、何もしない(モード異常なので)
+ return;
+ }
+ try
+ {
+ if (!camera.isTakingPicture())
+ {
+ // 連続撮影の開始
+ currentStatus = IIndicatorControl.shootingStatus.Starting;
+ camera.startTakingPicture(null, this);
+ indicator.onShootingStatusUpdate(currentStatus);
+ }
+ else
+ {
+ // 連続撮影の終了
+ currentStatus = IIndicatorControl.shootingStatus.Stopping;
+ camera.stopTakingPicture(this);
+ indicator.onShootingStatusUpdate(currentStatus);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onProgress(OLYCamera olyCamera, OLYCamera.TakingProgress takingProgress, OLYCameraAutoFocusResult olyCameraAutoFocusResult)
+ {
+ if (currentStatus == IIndicatorControl.shootingStatus.Stopping)
+ {
+ // 終了中の時にはなにもしない
+ return;
+ }
+
+ // 撮影中の更新処理
+ if (takingProgress != OLYCamera.TakingProgress.EndFocusing)
+ {
+ return;
+ }
+
+ String result = olyCameraAutoFocusResult.getResult();
+ if (result == null)
+ {
+ Log.v(TAG, "FocusResult is null.");
+ }
+ else switch (result)
+ {
+ case "ok":
+ RectF postFocusFrameRect = olyCameraAutoFocusResult.getRect();
+ if (postFocusFrameRect != null)
+ {
+ showFocusFrame(postFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Focused, 0.0);
+ }
+ break;
+
+ case "none":
+ default:
+ hideFocusFrame();
+ break;
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onCompleted()
+ {
+ Log.v(TAG, "SequentialShotControl::onCompleted()");
+ indicator.onShootingStatusUpdate(currentStatus);
+ if (currentStatus != IIndicatorControl.shootingStatus.Stopping)
+ {
+ // 撮影停止中以外ではなにもしない。
+ return;
+ }
+
+ // 撮影停止処理...
+ try
+ {
+ camera.clearAutoFocusPoint();
+ hideFocusFrame();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ currentStatus = IIndicatorControl.shootingStatus.Unknown;
+ indicator.onShootingStatusUpdate(currentStatus);
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ try
+ {
+ camera.clearAutoFocusPoint();
+ hideFocusFrame();
+ }
+ catch (Exception ee)
+ {
+ ee.printStackTrace();
+ }
+ e.printStackTrace();
+ currentStatus = IIndicatorControl.shootingStatus.Unknown;
+ }
+
+ /**
+ *
+ *
+ */
+ private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
+ {
+ if (frameDisplayer != null)
+ {
+ frameDisplayer.showFocusFrame(rect, status, duration);
+ }
+ indicator.onAfLockUpdate(IAutoFocusFrameDisplay.FocusFrameStatus.Focused == status);
+ }
+
+ /**
+ *
+ *
+ */
+ private void hideFocusFrame()
+ {
+ if (frameDisplayer != null)
+ {
+ frameDisplayer.hideFocusFrame();
+ }
+ indicator.onAfLockUpdate(false);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.operation.takepicture;
+
+import android.graphics.RectF;
+import android.util.Log;
+
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+import java.util.HashMap;
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
+
+
+/**
+ * 一枚撮影用のクラス
+ *
+ * Created by MRSa on 2016/06/18.
+ */
+public class SingleShotControl implements OLYCamera.TakePictureCallback
+{
+ private final String TAG = toString();
+ private final OLYCamera camera;
+ private final IIndicatorControl indicator;
+
+ private IAutoFocusFrameDisplay frameDisplayer = null;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ public SingleShotControl(OLYCamera camera, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ {
+ this.camera = camera;
+ this.frameDisplayer = frameDisplayer;
+ this.indicator = indicator;
+ }
+
+ /**
+ * 1枚撮影する
+ *
+ */
+ public void singleShot()
+ {
+ try
+ {
+ camera.takePicture(new HashMap<String, Object>(), this);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onProgress(OLYCamera olyCamera, OLYCamera.TakingProgress takingProgress, OLYCameraAutoFocusResult olyCameraAutoFocusResult)
+ {
+ if (takingProgress != OLYCamera.TakingProgress.EndFocusing)
+ {
+ return;
+ }
+
+ String result = olyCameraAutoFocusResult.getResult();
+ if (result == null)
+ {
+ Log.v(TAG, "FocusResult is null.");
+ }
+ else switch (result)
+ {
+ case "ok":
+ RectF postFocusFrameRect = olyCameraAutoFocusResult.getRect();
+ if (postFocusFrameRect != null)
+ {
+ showFocusFrame(postFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Focused, 0.0);
+ }
+ break;
+
+ case "none":
+ default:
+ hideFocusFrame();
+ break;
+ }
+ }
+
+ @Override
+ public void onCompleted()
+ {
+ try
+ {
+ camera.clearAutoFocusPoint();
+ hideFocusFrame();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ try
+ {
+ camera.clearAutoFocusPoint();
+ hideFocusFrame();
+ }
+ catch (Exception ee)
+ {
+ ee.printStackTrace();
+ }
+ e.printStackTrace();
+ //control.presentMessage(R.string.shutter_control_take_failed, e.getMessage());
+ }
+
+ private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
+ {
+ indicator.onAfLockUpdate(IAutoFocusFrameDisplay.FocusFrameStatus.Focused == status);
+ }
+
+ private void hideFocusFrame()
+ {
+ if (frameDisplayer != null)
+ {
+ frameDisplayer.hideFocusFrame();
+ }
+ indicator.onAfLockUpdate(false);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.wrapper;
+
+import android.graphics.PointF;
+import android.util.Log;
+import android.view.MotionEvent;
+
+import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
+import net.osdn.gokigen.a01d.camera.olympus.operation.takepicture.AutoFocusControl;
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+/**
+ *
+ *
+ */
+public class OlyCameraFocusControl implements IFocusingControl
+{
+ private final String TAG = toString();
+ private final AutoFocusControl afControl;
+ private final IAutoFocusFrameDisplay frameDisplay;
+
+ public OlyCameraFocusControl(OlyCameraWrapper wrapper, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ {
+ this.frameDisplay = frameDisplayer;
+ afControl = new AutoFocusControl(wrapper.getOLYCamera(), frameDisplayer, indicator);
+ }
+
+ @Override
+ public boolean driveAutoFocus(final MotionEvent motionEvent)
+ {
+ if (motionEvent.getAction() != MotionEvent.ACTION_DOWN)
+ {
+ return (false);
+ }
+ Log.v(TAG, "motionEvent() : pointOnView [" + Math.ceil(motionEvent.getX()) + "," + Math.ceil(motionEvent.getY()) + "] ");
+ if (frameDisplay != null)
+ {
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ PointF point = frameDisplay.getPointWithEvent(motionEvent);
+ if (frameDisplay.isContainsPoint(point))
+ {
+ afControl.lockAutoFocus(point);
+ }
+ }
+ });
+ try
+ {
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return (false);
+ }
+
+ @Override
+ public void unlockAutoFocus()
+ {
+ try
+ {
+ afControl.unlockAutoFocus();
+ frameDisplay.hideFocusFrame();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.wrapper;
+
+import android.util.Log;
+
+import java.util.Map;
+
+import jp.co.olympus.camerakit.OLYCamera;
+
+/**
+ *
+ */
+public class OlyCameraHardwareStatus implements ICameraHardwareStatus
+{
+ private final String TAG = toString();
+ private final OLYCamera camera;
+
+ /**
+ *
+ */
+ public OlyCameraHardwareStatus(OLYCamera camera)
+ {
+ this.camera = camera;
+ }
+
+ @Override
+ public String getLensMountStatus()
+ {
+ String message;
+ try
+ {
+ message = camera.getLensMountStatus();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ message = "[UNKNOWN]";
+ }
+ return (message);
+ }
+
+ @Override
+ public String getMediaMountStatus()
+ {
+ String message;
+ try
+ {
+ message = camera.getMediaMountStatus();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ message = "[UNKNOWN]";
+ }
+ return (message);
+ }
+
+ @Override
+ public float getMinimumFocalLength()
+ {
+ float value;
+ try
+ {
+ value = camera.getMinimumFocalLength();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ value = -1.0f;
+ }
+ return (value);
+ }
+
+ @Override
+ public float getMaximumFocalLength()
+ {
+ float value;
+ try
+ {
+ value = camera.getMaximumFocalLength();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ value = -1.0f;
+ }
+ return (value);
+ }
+
+ @Override
+ public float getActualFocalLength()
+ {
+ float value;
+ try
+ {
+ value = camera.getActualFocalLength();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ value = -1.0f;
+ }
+ return (value);
+ }
+
+ @Override
+ public Map<String, Object> inquireHardwareInformation()
+ {
+ try
+ {
+ return (camera.inquireHardwareInformation());
+ }
+ catch (Exception e)
+ {
+ Log.v(TAG, "EXCEPTION : " + e.toString());
+ e.printStackTrace();
+ }
+ return (null);
+ }
+}
import android.app.Activity;
+import net.osdn.gokigen.a01d.camera.olympus.IOlympusDisplayInjector;
import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ICameraStatusReceiver;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.OlyCameraConnection;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.OlyCameraPropertyProxy;
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
/**
*
*
*/
-public class OlympusInterfaceProvider implements IOlympusInterfaceProvider
+public class OlympusInterfaceProvider implements IOlympusInterfaceProvider, IOlympusDisplayInjector
{
private final OlyCameraWrapper wrapper;
private final OlyCameraConnection connection;
private final OlyCameraPropertyProxy propertyProxy;
+ private final OlyCameraHardwareStatus hardwareStatus;
+ private OlyCameraFocusControl focusControl = null;
public OlympusInterfaceProvider(Activity context, ICameraStatusReceiver provider)
{
this.wrapper = new OlyCameraWrapper(context);
this.connection = new OlyCameraConnection(context, this.wrapper.getOLYCamera(), provider);
this.propertyProxy = new OlyCameraPropertyProxy(this.wrapper.getOLYCamera());
+ this.hardwareStatus = new OlyCameraHardwareStatus(this.wrapper.getOLYCamera());
}
@Override
+ public void injectOlympusDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ {
+ focusControl = new OlyCameraFocusControl(wrapper, frameDisplayer, indicator);
+ }
+
+ @Override
public IOlyCameraConnection getOlyCameraConnection()
{
return (connection);
@Override
public ICameraHardwareStatus getHardwareStatus()
{
- return null;
+ return (hardwareStatus);
}
@Override
{
return (wrapper);
}
+
+ @Override
+ public IFocusingControl getFocusingControl()
+ {
+ return (focusControl);
+ }
}
* (OLYMPUS の ImageCaptureSample そのまま)
*
*/
-public class CameraLiveImageView extends View implements CameraLiveViewListenerImpl.IImageDataReceiver, IAutoFocusFrameDisplay, ILiveImageStatusNotify
+public class CameraLiveImageView extends View implements CameraLiveViewListenerImpl.IImageDataReceiver, IAutoFocusFrameDisplay, ILiveImageStatusNotify, IIndicatorControl
{
private final String TAG = this.toString();
if (imageRotationDegrees == 0 || imageRotationDegrees == 180) {
imageWidth = imageBitmap.getWidth();
imageHeight = imageBitmap.getHeight();
+ //imageWidth = this.getWidth();
+ //imageHeight = this.getHeight();
} else {
imageWidth = imageBitmap.getHeight();
imageHeight = imageBitmap.getWidth();
+ //imageWidth = this.getHeight();
+ //imageHeight = this.getWidth();
}
return (OLYCamera.convertPointOnLiveImageIntoViewfinder(pointOnImage, imageWidth, imageHeight, imageRotationDegrees));
}
imageSizeWidth = imageBitmap.getHeight();
imageSizeHeight = imageBitmap.getWidth();
}
+
float viewSizeWidth = this.getWidth();
float viewSizeHeight = this.getHeight();
float ratioX = viewSizeWidth / imageSizeWidth;
float ratioY = viewSizeHeight / imageSizeHeight;
- float scale;
+ float scale = 1.0f;
- switch (imageScaleType) {
+ switch (imageScaleType)
+ {
case FIT_XY:
imagePointX /= ratioX;
imagePointY /= ratioY;
break;
+
case FIT_CENTER: // go to next label.
case CENTER_INSIDE:
scale = Math.min(ratioX, ratioY);
- imagePointX -= (viewSizeWidth - imageSizeWidth * scale) / 2.0f;
- imagePointY -= (viewSizeHeight - imageSizeHeight * scale) / 2.0f;
- imagePointX /= scale;
- imagePointY /= scale;
+ imagePointX = imagePointX - (viewSizeWidth - imageSizeWidth * scale) / 2.0f;
+ imagePointY = imagePointY - (viewSizeHeight - imageSizeHeight * scale) / 2.0f;
+ imagePointX = imagePointX / scale;
+ imagePointY = imagePointY / scale;
break;
+
case CENTER_CROP:
scale = Math.max(ratioX, ratioY);
imagePointX -= (viewSizeWidth - imageSizeWidth * scale) / 2.0f;
imagePointX /= scale;
imagePointY /= scale;
break;
+
case CENTER:
imagePointX -= (viewSizeWidth - imageSizeWidth) / 2.0f;
imagePointY -= (viewSizeHeight - imageSizeHeight) / 2.0f;
break;
+
default:
break;
}
-
- return new PointF(imagePointX, imagePointY);
+ //return new PointF((imagePointX / scale), (imagePointY / scale));
+ return new PointF((imagePointX), (imagePointY));
}
/**
return (messageHolder.getMessageDrawer());
}
+
+ /**
+ * IIndicatorControl の実装
+ *
+ *
+ *
+ */
+ @Override
+ public void onAfLockUpdate(boolean isAfLocked)
+ {
+ //Log.v(TAG, "onAfLockUpdate() : " + isAfLocked);
+ }
+
+ @Override
+ public void onShootingStatusUpdate(shootingStatus status)
+ {
+ //Log.v(TAG, "onShootingStatusUpdate() : " + status);
+ }
+
+ @Override
+ public void onMovieStatusUpdate(shootingStatus status)
+ {
+ //Log.v(TAG, "onMovieStatusUpdate() : " + status);
+ }
+
+ @Override
+ public void onBracketingStatusUpdate(String message)
+ {
+ // Log.v(TAG, "onBracketingStatusUpdate() : " + message);
+ }
}
--- /dev/null
+package net.osdn.gokigen.a01d.liveview;
+
+public interface IIndicatorControl
+{
+ // 撮影状態の記録
+ enum shootingStatus
+ {
+ Unknown,
+ Starting,
+ Stopping,
+ }
+
+ void onAfLockUpdate(boolean isAfLocked);
+ void onShootingStatusUpdate(shootingStatus status);
+ void onMovieStatusUpdate(shootingStatus status);
+ void onBracketingStatusUpdate(String message);
+}
package net.osdn.gokigen.a01d.liveview;
import android.util.Log;
+import android.view.MotionEvent;
import android.view.View;
import net.osdn.gokigen.a01d.IChangeScene;
import net.osdn.gokigen.a01d.R;
+import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
/**
*
*
*/
-class LiveViewClickListener implements View.OnClickListener
+class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchListener
{
- final String TAG = toString();
- final ILiveImageStatusNotify statusNotify;
- final IStatusViewDrawer statusViewDrawer;
- final IChangeScene changeScene;
+ private final String TAG = toString();
+ private final ILiveImageStatusNotify statusNotify;
+ private final IStatusViewDrawer statusViewDrawer;
+ private final IChangeScene changeScene;
+ private final IFocusingControl focusingControl;
-
- LiveViewClickListener(ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene)
+ LiveViewClickTouchListener(ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IFocusingControl focusingControl)
{
this.statusNotify = imageStatusNotify;
this.statusViewDrawer = statusView;
this.changeScene = changeScene;
+ this.focusingControl = focusingControl;
}
-
+ /**
+ * オブジェクトをクリックする処理
+ *
+ */
@Override
public void onClick(View view)
{
int id = view.getId();
+ Log.v(TAG, "onClick() " + id);
try
{
switch (id)
e.printStackTrace();
}
}
+
+ /**
+ * オブジェクトをタッチする処理
+ *
+ */
+ @Override
+ public boolean onTouch(View view, MotionEvent motionEvent)
+ {
+ int id = view.getId();
+ Log.v(TAG, "onTouch() : " + id);
+ return ((id == R.id.cameraLiveImageView)&&(focusingControl.driveAutoFocus(motionEvent)));
+ }
}
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
-import android.widget.ImageView;
import android.widget.TextView;
import net.osdn.gokigen.a01d.IChangeScene;
import net.osdn.gokigen.a01d.R;
+import net.osdn.gokigen.a01d.camera.olympus.IOlympusDisplayInjector;
+import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ILiveViewControl;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
private static final int COMMAND_MY_PROPERTY = 0x00000100;
private ILiveViewControl liveViewControl = null;
+ private IOlympusInterfaceProvider interfaceProvider = null;
+ private IOlympusDisplayInjector interfaceInjector = null;
// private IOlyCameraCoordinator camera = null;
// private MyInterfaceProvider factory = null;
private IChangeScene changeScene = null;
- private LiveViewClickListener onClickListener = null;
+ private IFocusingControl focusingControl = null;
+
+ private LiveViewClickTouchListener onClickTouchListener = null;
private TextView statusArea = null;
private View myView = null;
private String messageValue = "";
-
/**
*
*
/*
-
if (onTouchListener == null)
{
onTouchListener = new OlyCameraLiveViewOnTouchListener(getContext().getApplicationContext());
super.onCreateView(inflater, container, savedInstanceState);
Log.v(TAG, "onCreateView()");
-
if ((imageViewCreated)&&(myView != null))
{
// Viewを再利用。。。
Log.v(TAG, "onCreateView() : called again, so do nothing... : " + myView);
return (myView);
}
+
View view = inflater.inflate(R.layout.fragment_live_view, container, false);
myView = view;
imageViewCreated = true;
+ try
+ {
+ imageView = view.findViewById(R.id.cameraLiveImageView);
+ if (interfaceInjector != null)
+ {
+ interfaceInjector.injectOlympusDisplay(imageView, imageView);
+ }
+ if ((interfaceProvider != null) &&(focusingControl == null))
+ {
+ focusingControl = interfaceProvider.getFocusingControl();
+ }
+ if (onClickTouchListener == null)
+ {
+ onClickTouchListener = new LiveViewClickTouchListener(imageView, this, changeScene, focusingControl);
+ }
+ imageView.setOnClickListener(onClickTouchListener);
+ imageView.setOnTouchListener(onClickTouchListener);
- imageView = view.findViewById(R.id.cameraLiveImageView);
+ view.findViewById(R.id.show_preference_button).setOnClickListener(onClickTouchListener);
+ view.findViewById(R.id.camera_property_settings_button).setOnClickListener(onClickTouchListener);
- if (onClickListener == null)
+ showGrid = view.findViewById(R.id.show_hide_grid_button);
+ showGrid.setOnClickListener(onClickTouchListener);
+ updateGridIcon();
+
+ connectStatus = view.findViewById(R.id.connect_disconnect_button);
+ connectStatus.setOnClickListener(onClickTouchListener);
+ updateConnectionStatus(IOlyCameraConnection.CameraConnectionStatus.UNKNOWN);
+
+ statusArea = view.findViewById(R.id.informationMessageTextView);
+ }
+ catch (Exception e)
{
- onClickListener = new LiveViewClickListener(imageView, this, changeScene);
+ e.printStackTrace();
}
/*
focusAssist = (ImageView) view.findViewById(R.id.FocusAssistImageView);
focusAssist.setOnClickListener(onTouchListener);
*/
- try
- {
- view.findViewById(R.id.show_preference_button).setOnClickListener(onClickListener);
- view.findViewById(R.id.camera_property_settings_button).setOnClickListener(onClickListener);
-
- showGrid = view.findViewById(R.id.show_hide_grid_button);
- showGrid.setOnClickListener(onClickListener);
- updateGridIcon();
-
- connectStatus = view.findViewById(R.id.connect_disconnect_button);
- connectStatus.setOnClickListener(onClickListener);
- updateConnectionStatus(IOlyCameraConnection.CameraConnectionStatus.UNKNOWN);
-
- statusArea = view.findViewById(R.id.informationMessageTextView);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
+
+
+
+
return (view);
}
/**
*
*/
- public void prepare(IChangeScene sceneSelector, ILiveViewControl liveViewControl)
+ public void prepare(IChangeScene sceneSelector, IOlympusInterfaceProvider interfaceProvider, IOlympusDisplayInjector interfaceInjector)
{
this.changeScene = sceneSelector;
- this.liveViewControl = liveViewControl;
+ this.interfaceProvider = interfaceProvider;
+ this.liveViewControl = interfaceProvider.getLiveViewControl();
+ this.interfaceInjector = interfaceInjector;
}
/**