{
boolean driveAutoFocus(MotionEvent motionEvent);
void unlockAutoFocus();
+ void halfPressShutter(boolean isPressed);
}
}
}
+ @Override
+ public void halfPressShutter(boolean isPressed)
+ {
+ if (isPressed)
+ {
+ // 中心にフォーカスを合わせる
+ if (frameDisplay != null)
+ {
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ PointF point = new PointF(0.5f, 0.5f);
+ if (frameDisplay.isContainsPoint(point))
+ {
+ afControl.lockAutoFocus(point);
+ }
+ }
+ });
+ try
+ {
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ else
+ {
+ // フォーカスを解除する
+ unlockAutoFocus();
+ }
+ }
+
}
{
afControl.unlockAutoFocus();
}
+
+ @Override
+ public void halfPressShutter(boolean isPressed)
+ {
+ afControl.halfPressShutter(isPressed);
+ }
}
import android.support.annotation.NonNull;
import android.util.Log;
-import net.osdn.gokigen.a01d.camera.sony.operation.takepicture.SonyAutoFocusControl;
import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
private static final String TAG = RicohGr2AutoFocusControl.class.getSimpleName();
private final IIndicatorControl indicator;
private final IAutoFocusFrameDisplay frameDisplayer;
- private String lockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/lock";
+ private String lockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/lock"; // Pentax機の場合は /v1/lens/focus
private String unlockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/unlock";
+ private String halfPressShutterUrl = "http://192.168.0.1/_gr";
private int timeoutMs = 6000;
*
*
*/
+ public void halfPressShutter(final boolean isPressed)
+ {
+ Log.v(TAG, "halfPressShutter() " + isPressed);
+ try
+ {
+ Thread thread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ String postData = (isPressed) ? "cmd=baf 1" : "cmd=baf 0";
+ String result = SimpleHttpClient.httpPost(halfPressShutterUrl, postData, timeoutMs);
+ if ((result == null)||(result.length() < 1))
+ {
+ Log.v(TAG, "halfPressShutter() [" + isPressed + "] reply is null.");
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ *
+ *
+ */
private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
{
frameDisplayer.showFocusFrame(rect, status, duration);
e.printStackTrace();
}
}
+
+ @Override
+ public void halfPressShutter(boolean isPressed)
+ {
+ Log.v(TAG, "halfPressShutter() " + isPressed);
+ try
+ {
+ afControl.halfPressShutter(isPressed);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
}
}
/**
+ * シャッター半押し処理
+ *
+ */
+ public void halfPressShutter(final boolean isPressed)
+ {
+ Log.v(TAG, "halfPressShutter() : " + isPressed);
+ if (cameraApi == null)
+ {
+ Log.v(TAG, "ISonyCameraApi is null...");
+ return;
+ }
+ try
+ {
+ Thread thread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ JSONObject resultsObj = (isPressed) ? cameraApi.actHalfPressShutter() : cameraApi.cancelHalfPressShutter();
+ if (resultsObj == null)
+ {
+ Log.v(TAG, "lockAutoFocus() [" + isPressed + "] reply is null.");
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
*
*
*/
JSONObject getTouchAFPosition();
JSONObject cancelTouchAFPosition();
+ JSONObject actHalfPressShutter();
+ JSONObject cancelHalfPressShutter();
+
JSONObject setFocusMode(String focusMode);
JSONObject getFocusMode();
JSONObject getSupportedFocusMode();
}
@Override
+ public JSONObject actHalfPressShutter()
+ {
+ try
+ {
+ return (communicateJSON("camera", "actHalfPressShutter", new JSONArray(), "1.0", -1));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (new JSONObject());
+ }
+
+ @Override
+ public JSONObject cancelHalfPressShutter()
+ {
+ try
+ {
+ return (communicateJSON("camera", "cancelHalfPressShutter", new JSONArray(), "1.0", -1));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (new JSONObject());
+ }
+
+ @Override
public JSONObject setFocusMode(String focusMode)
{
try
actionZoomout();
break;
+ case R.id.focus_indicator:
+ // フォーカスインジケータをクリックした
+ actionFocusButton();
+ break;
+
default:
Log.v(TAG, "onClick() : " + id);
break;
}
/**
+ * フォーカスボタンが押されたとき...
+ *
+ */
+ private void actionFocusButton()
+ {
+
+
+
+ }
+
+ /**
* お気に入り設定ダイアログの表示
*
*/
view.findViewById(R.id.shutter_button).setOnClickListener(onClickTouchListener);
view.findViewById(R.id.btn_zoomin).setOnClickListener(onClickTouchListener);
view.findViewById(R.id.btn_zoomout).setOnClickListener(onClickTouchListener);
+ view.findViewById(R.id.focus_indicator).setOnClickListener(onClickTouchListener);
manualFocus = view.findViewById(R.id.focusing_button);
changeLiveViewScale = view.findViewById(R.id.live_view_scale_button);
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2v4h2L5,5zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4z"/>
+</vector>
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M3,5v4h2L5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2zM5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2z"/>
+</vector>
android:visibility="visible"
/>
+ <ImageView
+ android:id="@+id/focus_indicator"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@id/live_view_scale_button"
+ android:layout_alignStart="@id/live_view_scale_button"
+ android:layout_marginStart="8pt"
+ android:layout_marginLeft="8pt"
+ android:layout_marginBottom="3pt"
+ android:layout_above="@id/live_view_scale_button"
+ android:clickable="true"
+ android:contentDescription="@string/button"
+ android:focusable="true"
+ android:gravity="center"
+ android:scaleType="fitCenter"
+ android:src="@drawable/ic_crop_free_black_24dp"
+ android:visibility="visible" />
+
<TextView
android:id="@+id/focal_length_with_digital_zoom_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2pt"
android:layout_marginEnd="2pt"
- android:layout_above="@id/live_view_scale_button"
+ android:layout_above="@id/focus_indicator"
android:layout_alignLeft="@id/live_view_scale_button"
android:layout_alignStart="@id/live_view_scale_button"
android:layout_marginLeft="4pt"
<ImageView
android:id="@+id/focusing_button"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
+ android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
- android:layout_alignParentTop="true"
+ android:layout_alignParentBottom="true"
android:layout_marginLeft="2pt"
android:layout_marginStart="2pt"
android:clickable="true"
android:visibility="visible"
android:src="@drawable/ic_zoom_in_black_24dp" />
+ <ImageView
+ android:id="@+id/focus_indicator"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignTop="@id/live_view_scale_button"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentLeft="true"
+ android:layout_marginStart="4pt"
+ android:layout_marginLeft="4pt"
+ android:clickable="true"
+ android:contentDescription="@string/button"
+ android:focusable="true"
+ android:gravity="center"
+ android:scaleType="fitEnd"
+ android:src="@drawable/ic_crop_free_black_24dp"
+ android:visibility="visible" />
+
</RelativeLayout>
<RelativeLayout