• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

OPC(Olympus Air)用望遠鏡アプリ。


Commit MetaInfo

Révision9de5b374510033df8922f8bed9eee4fc0c179e36 (tree)
l'heure2018-06-13 00:25:23
AuteurMRSa <mrsa@myad...>
CommiterMRSa

Message de Log

Zoom-in / Zoom-out ボタンを用意した。(まずはOPCのみ)

Change Summary

Modification

--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/IZoomLensControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/IZoomLensControl.java
@@ -13,6 +13,7 @@ public interface IZoomLensControl
1313 float getMinimumFocalLength();
1414 float getCurrentFocalLength();
1515 void driveZoomLens(float targetLength);
16+ void driveZoomLens(boolean isZoomIn);
1617 void moveInitialZoomPosition();
1718 boolean isDrivingZoomLens();
1819
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraZoomLensControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraZoomLensControl.java
@@ -94,6 +94,9 @@ class OlyCameraZoomLensControl implements IZoomLensControl
9494 {
9595 try
9696 {
97+ // 現在位置を設定する
98+ initialize();
99+
97100 // レンズがサポートする焦点距離と、現在の焦点距離を取得する
98101 float targetFocalLength = targetLength;
99102
@@ -123,6 +126,55 @@ class OlyCameraZoomLensControl implements IZoomLensControl
123126 }
124127
125128 /**
129+ * ズームレンズを動作させる
130+ *
131+ * @param isZoomIn 寄る方向に動かす場合は true
132+ */
133+ @Override
134+ public void driveZoomLens(boolean isZoomIn)
135+ {
136+ try
137+ {
138+ // 現在位置を設定する
139+ initialize();
140+ float targetFocalLength = currentLength;
141+ if (isZoomIn)
142+ {
143+ // 寄る
144+ targetFocalLength = targetFocalLength * 1.15f;
145+ }
146+ else
147+ {
148+ // 引く
149+ targetFocalLength = targetFocalLength * 0.9f;
150+ }
151+
152+ // 焦点距離が最大値・最小値を超えないようにする
153+ if (targetFocalLength > maximumLength)
154+ {
155+ targetFocalLength = maximumLength;
156+ }
157+ if (targetFocalLength < minimumLength)
158+ {
159+ targetFocalLength = minimumLength;
160+ }
161+
162+ // レンズのスーム操作
163+ Log.v(TAG, "ZOOM from " + currentLength + "mm to " + targetFocalLength + "mm");
164+
165+ // ズーム動作中でない時には、レンズをズームさせる
166+ if (!camera.isDrivingZoomLens())
167+ {
168+ camera.startDrivingZoomLensToFocalLength(targetFocalLength);
169+ }
170+ }
171+ catch (Exception e)
172+ {
173+ e.printStackTrace();
174+ }
175+ }
176+
177+ /**
126178 * ズームレンズの初期位置に移動させる
127179 */
128180 @Override
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/SonyCameraZoomLensControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/SonyCameraZoomLensControl.java
@@ -16,7 +16,7 @@ public class SonyCameraZoomLensControl implements IZoomLensControl
1616 @Override
1717 public boolean canZoom() {
1818 Log.v(TAG, "canZoom()");
19- return false;
19+ return (true);
2020 }
2121
2222 @Override
@@ -53,6 +53,12 @@ public class SonyCameraZoomLensControl implements IZoomLensControl
5353 }
5454
5555 @Override
56+ public void driveZoomLens(boolean isZoomIn)
57+ {
58+ Log.v(TAG, "driveZoomLens() : " + isZoomIn);
59+ }
60+
61+ @Override
5662 public void moveInitialZoomPosition()
5763 {
5864 Log.v(TAG, "moveInitialZoomPosition()");
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/takepicture/SonyAutoFocusControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/sony/operation/takepicture/SonyAutoFocusControl.java
@@ -178,10 +178,8 @@ public class SonyAutoFocusControl
178178 */
179179 private RectF getPreFocusFrameRect(@NonNull PointF point)
180180 {
181- float imageWidth = 1.0f;
182- float imageHeight = 1.0f;
183- imageWidth = frameDisplayer.getContentSizeWidth();
184- imageHeight = frameDisplayer.getContentSizeHeight();
181+ float imageWidth = frameDisplayer.getContentSizeWidth();
182+ float imageHeight = frameDisplayer.getContentSizeHeight();
185183
186184 // Display a provisional focus frame at the touched point.
187185 float focusWidth = 0.125f; // 0.125 is rough estimate.
@@ -222,5 +220,4 @@ public class SonyAutoFocusControl
222220 }
223221 return (afResult);
224222 }
225-
226223 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewClickTouchListener.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewClickTouchListener.java
@@ -15,6 +15,7 @@ import net.osdn.gokigen.a01d.camera.ICaptureControl;
1515 import net.osdn.gokigen.a01d.camera.IFocusingControl;
1616 import net.osdn.gokigen.a01d.camera.ICameraInformation;
1717 import net.osdn.gokigen.a01d.camera.ICameraConnection;
18+import net.osdn.gokigen.a01d.camera.IZoomLensControl;
1819 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
1920 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
2021 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
@@ -37,6 +38,7 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
3738 private final ICameraInformation cameraInformation;
3839 private final ICameraConnection cameraConnection;
3940 private final IFavoriteSettingDialogKicker dialogKicker;
41+ private final IZoomLensControl zoomLensControl;
4042
4143 LiveViewClickTouchListener(Context context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IInterfaceProvider interfaceProvider, IFavoriteSettingDialogKicker dialogKicker)
4244 {
@@ -53,6 +55,7 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
5355 this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
5456 this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
5557 this.cameraConnection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
58+ this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
5659 }
5760 else
5861 {
@@ -61,6 +64,7 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
6164 this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
6265 this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
6366 this.cameraConnection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
67+ this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
6468 }
6569 this.dialogKicker = dialogKicker;
6670 }
@@ -119,6 +123,15 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
119123 showFavoriteDialog();
120124 break;
121125
126+ case R.id.btn_zoomin:
127+ // ズームインのボタンが押された
128+ actionZoomin();
129+ break;
130+ case R.id.btn_zoomout:
131+ // ズームアウトのボタンが押された
132+ actionZoomout();
133+ break;
134+
122135 default:
123136 Log.v(TAG, "onClick() : " + id);
124137 break;
@@ -130,6 +143,43 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
130143 }
131144 }
132145
146+ private void actionZoomin()
147+ {
148+ Log.v(TAG, "actionZoomin()");
149+ try
150+ {
151+ // ズーム可能な場合、ズームインする
152+ if (zoomLensControl.canZoom())
153+ {
154+ zoomLensControl.driveZoomLens(true);
155+ }
156+ }
157+ catch (Exception e)
158+ {
159+ e.printStackTrace();
160+ }
161+ }
162+
163+ private void actionZoomout()
164+ {
165+ Log.v(TAG, "actionZoomout()");
166+ try
167+ {
168+ // ズーム可能な場合、ズームアウトする
169+ if (zoomLensControl.canZoom())
170+ {
171+ zoomLensControl.driveZoomLens(false);
172+ }
173+ }
174+ catch (Exception e)
175+ {
176+ e.printStackTrace();
177+ }
178+ }
179+
180+
181+
182+
133183 /**
134184 * シャッターボタンが押された時の処理
135185 *
--- a/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewFragment.java
@@ -149,6 +149,8 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
149149 view.findViewById(R.id.camera_property_settings_button).setOnClickListener(onClickTouchListener);
150150 view.findViewById(R.id.shutter_button).setOnClickListener(onClickTouchListener);
151151 view.findViewById(R.id.show_favorite_settings_button).setOnClickListener(onClickTouchListener);
152+ view.findViewById(R.id.btn_zoomin).setOnClickListener(onClickTouchListener);
153+ view.findViewById(R.id.btn_zoomout).setOnClickListener(onClickTouchListener);
152154
153155 manualFocus = view.findViewById(R.id.focusing_button);
154156 if (manualFocus != null)
--- /dev/null
+++ b/app/src/main/res/drawable/ic_zoom_in_black_24dp.xml
@@ -0,0 +1,9 @@
1+<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+ android:width="24dp"
3+ android:height="24dp"
4+ android:viewportWidth="24.0"
5+ android:viewportHeight="24.0">
6+ <path
7+ android:fillColor="#FF000000"
8+ android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14zM12,10h-2v2L9,12v-2L7,10L7,9h2L9,7h1v2h2v1z"/>
9+</vector>
--- /dev/null
+++ b/app/src/main/res/drawable/ic_zoom_out_black_24dp.xml
@@ -0,0 +1,9 @@
1+<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+ android:width="24dp"
3+ android:height="24dp"
4+ android:viewportWidth="24.0"
5+ android:viewportHeight="24.0">
6+ <path
7+ android:fillColor="#FF000000"
8+ android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14zM7,9h5v1L7,10z"/>
9+</vector>
--- a/app/src/main/res/layout-land/fragment_live_view.xml
+++ b/app/src/main/res/layout-land/fragment_live_view.xml
@@ -17,25 +17,57 @@
1717 android:background="@color/background_translucent_dark"
1818 android:orientation="horizontal">
1919
20- <view
21- android:id="@+id/consoleImageView1"
22- class="net.osdn.gokigen.a01d.liveview.ScalableImageViewPanel"
20+ <RelativeLayout
21+ android:id="@+id/zoomPanelLayout"
2322 android:layout_width="0dip"
2423 android:layout_height="fill_parent"
2524 android:layout_weight="1"
26- android:clickable="true"
27- android:focusable="true"
28- android:contentDescription="@string/favorite"
29- android:gravity="center"
30- android:scaleType="fitCenter"
31- android:visibility="visible" />
25+ android:background="@color/background_translucent_dark"
26+ android:orientation="vertical">
27+
28+ <ImageButton
29+ android:id="@+id/btn_zoomin"
30+ android:layout_width="match_parent"
31+ android:layout_height="wrap_content"
32+ android:layout_alignParentTop="true"
33+ android:contentDescription="@string/button"
34+ android:clickable="true"
35+ android:focusable="true"
36+ android:scaleType="fitCenter"
37+ android:visibility="visible"
38+ android:src="@drawable/ic_zoom_in_black_24dp" />
3239
40+ <view
41+ android:id="@+id/consoleImageView1"
42+ class="net.osdn.gokigen.a01d.liveview.ScalableImageViewPanel"
43+ android:layout_width="match_parent"
44+ android:layout_height="match_parent"
45+ android:clickable="true"
46+ android:focusable="true"
47+ android:contentDescription="@string/favorite"
48+ android:gravity="center"
49+ android:scaleType="fitCenter"
50+ android:visibility="gone" />
51+
52+ <ImageButton
53+ android:id="@+id/btn_zoomout"
54+ android:layout_width="match_parent"
55+ android:layout_height="wrap_content"
56+ android:layout_alignParentBottom="true"
57+ android:contentDescription="@string/button"
58+ android:clickable="true"
59+ android:focusable="true"
60+ android:scaleType="fitCenter"
61+ android:visibility="visible"
62+ android:src="@drawable/ic_zoom_out_black_24dp" />
63+
64+ </RelativeLayout>
3365 <view
3466 android:id="@+id/cameraLiveImageView"
3567 class="net.osdn.gokigen.a01d.liveview.CameraLiveImageView"
3668 android:layout_width="0dip"
3769 android:layout_height="fill_parent"
38- android:layout_weight="7"
70+ android:layout_weight="8"
3971 android:gravity="center"
4072 android:scaleType="fitCenter"
4173 android:visibility="visible" />
--- a/app/src/main/res/layout/fragment_live_view.xml
+++ b/app/src/main/res/layout/fragment_live_view.xml
@@ -1,6 +1,7 @@
11 <?xml version="1.0" encoding="utf-8"?>
22
33 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4+ xmlns:app="http://schemas.android.com/apk/res-auto"
45 xmlns:tools="http://schemas.android.com/tools"
56 android:orientation="vertical"
67 android:layout_width="match_parent"
@@ -51,68 +52,97 @@
5152 android:id="@+id/focusing_button"
5253 android:layout_width="wrap_content"
5354 android:layout_height="match_parent"
55+ android:layout_alignParentLeft="true"
56+ android:layout_alignParentStart="true"
57+ android:layout_alignParentTop="true"
58+ android:layout_marginLeft="2pt"
59+ android:layout_marginStart="2pt"
5460 android:clickable="true"
61+ android:contentDescription="@string/button"
5562 android:focusable="true"
5663 android:gravity="center"
5764 android:scaleType="fitEnd"
58- android:contentDescription="@string/button"
5965 android:src="@drawable/btn_manual_focus"
60- android:visibility="visible"
61- android:layout_marginLeft="2pt"
62- android:layout_marginStart="2pt"
63- android:layout_alignParentTop="true"
64- android:layout_alignParentLeft="true"
65- android:layout_alignParentStart="true"
66- />
66+ android:visibility="visible" />
6767
6868 <ImageButton
6969 android:id="@+id/shutter_button"
7070 android:layout_width="wrap_content"
7171 android:layout_height="match_parent"
72+ android:layout_alignParentTop="true"
73+ android:layout_centerHorizontal="true"
7274 android:clickable="true"
75+ android:contentDescription="@string/button"
7376 android:focusable="true"
7477 android:gravity="center"
7578 android:scaleType="fitCenter"
76- android:contentDescription="@string/button"
7779 android:src="@drawable/ic_camera_black_24dp"
78- android:visibility="visible"
79- android:layout_alignParentTop="true"
80- android:layout_centerHorizontal="true" />
80+ android:visibility="visible" />
8181
8282 <Button
8383 android:id="@+id/live_view_scale_button"
8484 android:layout_width="wrap_content"
8585 android:layout_height="match_parent"
86- android:layout_marginRight="2pt"
87- android:layout_marginEnd="2pt"
8886 android:layout_alignParentBottom="true"
89- android:layout_alignParentRight="true"
9087 android:layout_alignParentEnd="true"
88+ android:layout_alignParentRight="true"
89+ android:layout_marginEnd="2pt"
90+ android:layout_marginRight="2pt"
9191 android:clickable="true"
92+ android:contentDescription="@string/button"
9293 android:focusable="true"
9394 android:text="@string/live_view_scale_default"
94- android:contentDescription="@string/button"
95- android:visibility="visible"
96- />
95+ android:visibility="visible" />
9796
9897 <TextView
9998 android:id="@+id/focal_length_with_digital_zoom_view"
10099 android:layout_width="wrap_content"
101100 android:layout_height="match_parent"
102- android:layout_marginRight="2pt"
103101 android:layout_marginEnd="2pt"
104- android:layout_toLeftOf="@id/live_view_scale_button"
105- android:layout_toStartOf="@id/live_view_scale_button"
106- android:layout_toRightOf="@id/shutter_button"
107- android:layout_toEndOf="@id/shutter_button"
108102 android:layout_marginLeft="4pt"
103+ android:layout_marginRight="2pt"
109104 android:layout_marginStart="4pt"
105+ android:layout_toEndOf="@id/shutter_button"
106+ android:layout_toLeftOf="@id/live_view_scale_button"
107+ android:layout_toRightOf="@id/shutter_button"
108+ android:layout_toStartOf="@id/live_view_scale_button"
109+ android:contentDescription="@string/button"
110+ android:clickable="true"
111+ android:focusable="true"
110112 android:gravity="center"
111113 android:scaleType="fitCenter"
112114 android:text="@string/focal_length_with_digital_zoom_view_default"
115+ android:visibility="visible" />
116+
117+ <ImageButton
118+ android:id="@+id/btn_zoomout"
119+ android:layout_width="wrap_content"
120+ android:layout_height="match_parent"
121+ android:layout_alignParentStart="true"
122+ android:layout_alignParentLeft="true"
123+ android:layout_alignParentTop="true"
124+ android:layout_marginStart="45dp"
125+ android:layout_marginLeft="45dp"
126+ android:contentDescription="@string/button"
127+ android:clickable="true"
128+ android:focusable="true"
129+ android:scaleType="fitCenter"
130+ android:visibility="visible"
131+ android:src="@drawable/ic_zoom_out_black_24dp" />
132+
133+ <ImageButton
134+ android:id="@+id/btn_zoomin"
135+ android:layout_width="wrap_content"
136+ android:layout_height="match_parent"
137+ android:layout_alignParentStart="true"
138+ android:layout_alignParentLeft="true"
139+ android:layout_alignParentTop="true"
140+ android:layout_marginStart="100dp"
141+ android:layout_marginLeft="100dp"
113142 android:contentDescription="@string/button"
143+ android:scaleType="fitCenter"
114144 android:visibility="visible"
115- />
145+ android:src="@drawable/ic_zoom_in_black_24dp" />
116146
117147 </RelativeLayout>
118148
Afficher sur ancien navigateur de dépôt.