リビジョン | 4d1c7f26553d3deaa1b7d6da4665176393496daa (tree) |
---|---|
日時 | 2018-01-30 00:27:23 |
作者 | MRSa <mrsa@myad...> |
コミッター | MRSa |
画面右下および左下のAF動作外のエリアをタッチしたときにボタンアクションを実行できるようにする。(暫定)
@@ -32,15 +32,15 @@ android { | ||
32 | 32 | dependencies { |
33 | 33 | compile fileTree(dir: 'libs', include: ['*.jar']) |
34 | 34 | wearApp project(path: ':wear') |
35 | - provided 'com.google.android.wearable:wearable:2.1.0' | |
36 | - compile 'com.google.android.support:wearable:2.1.0' | |
37 | - compile 'com.google.android.gms:play-services-wearable:11.4.2' | |
35 | + provided 'com.google.android.wearable:wearable:2.2.0' | |
36 | + compile 'com.google.android.support:wearable:2.2.0' | |
37 | + compile 'com.google.android.gms:play-services-wearable:11.8.0' | |
38 | 38 | |
39 | - compile 'com.android.support:animated-vector-drawable:27.0.0' | |
40 | - compile 'com.android.support:percent:27.0.0' | |
41 | - compile 'com.android.support:support-vector-drawable:27.0.0' | |
42 | - compile 'com.android.support:appcompat-v7:27.0.0' | |
43 | - compile 'com.android.support:preference-v7:27.0.0' | |
44 | - compile 'com.android.support:exifinterface:27.0.0' | |
45 | - compile 'com.android.support:support-v4:27.0.0' | |
39 | + compile 'com.android.support:animated-vector-drawable:27.0.2' | |
40 | + compile 'com.android.support:percent:27.0.2' | |
41 | + compile 'com.android.support:support-vector-drawable:27.0.2' | |
42 | + compile 'com.android.support:appcompat-v7:27.0.2' | |
43 | + compile 'com.android.support:preference-v7:27.0.2' | |
44 | + compile 'com.android.support:exifinterface:27.0.2' | |
45 | + compile 'com.android.support:support-v4:27.0.2' | |
46 | 46 | } |
@@ -5,7 +5,7 @@ buildscript { | ||
5 | 5 | jcenter() |
6 | 6 | } |
7 | 7 | dependencies { |
8 | - classpath 'com.android.tools.build:gradle:3.0.0' | |
8 | + classpath 'com.android.tools.build:gradle:3.0.1' | |
9 | 9 | |
10 | 10 | // NOTE: Do not place your application dependencies here; they belong |
11 | 11 | // in the individual module build.gradle files |
@@ -21,17 +21,17 @@ android { | ||
21 | 21 | dependencies { |
22 | 22 | compile fileTree(include: ['*.jar'], dir: 'libs') |
23 | 23 | |
24 | - provided 'com.google.android.wearable:wearable:2.1.0' | |
25 | - compile 'com.google.android.support:wearable:2.1.0' | |
26 | - compile 'com.google.android.gms:play-services-wearable:11.4.2' | |
24 | + provided 'com.google.android.wearable:wearable:2.2.0' | |
25 | + compile 'com.google.android.support:wearable:2.2.0' | |
26 | + compile 'com.google.android.gms:play-services-wearable:11.8.0' | |
27 | 27 | |
28 | 28 | //compile 'com.android.support:wear:26.0.0' |
29 | - compile 'com.android.support:animated-vector-drawable:27.0.0' | |
30 | - compile 'com.android.support:percent:27.0.0' | |
31 | - compile 'com.android.support:support-vector-drawable:27.0.0' | |
32 | - compile 'com.android.support:appcompat-v7:27.0.0' | |
33 | - compile 'com.android.support:preference-v7:27.0.0' | |
34 | - compile 'com.android.support:exifinterface:27.0.0' | |
35 | - compile 'com.android.support:support-v4:27.0.0' | |
29 | + compile 'com.android.support:animated-vector-drawable:27.0.2' | |
30 | + compile 'com.android.support:percent:27.0.2' | |
31 | + compile 'com.android.support:support-vector-drawable:27.0.2' | |
32 | + compile 'com.android.support:appcompat-v7:27.0.2' | |
33 | + compile 'com.android.support:preference-v7:27.0.2' | |
34 | + compile 'com.android.support:exifinterface:27.0.2' | |
35 | + compile 'com.android.support:support-v4:27.0.2' | |
36 | 36 | compile files('libs/olycamerakit.jar') |
37 | 37 | } |
@@ -121,11 +121,92 @@ public class OlyCameraLiveViewOnTouchListener implements View.OnClickListener, | ||
121 | 121 | Log.v(TAG, "onTouch() : prohibit operation"); |
122 | 122 | return ((operationMode == IShowInformation.operation.ONLY_CONNECT)&&(changeScene.showConnectionStatus())); |
123 | 123 | } |
124 | - // 現在のところ、タッチエリアの場合はオートフォーカス実行で固定 | |
124 | + | |
125 | + // 画面下部のエリア(オートフォーカスエリア外)をタッチした場合には、ボタン押下アクションに切り替える | |
126 | + int hookId = checkHookTouchedPosition(v, event); | |
127 | + if (hookId != 0) | |
128 | + { | |
129 | + boolean ret = false; | |
130 | + if (hookId == R.id.liveview) | |
131 | + { | |
132 | + // 何もしないパターン。。。 | |
133 | + return (true); | |
134 | + } | |
135 | + try | |
136 | + { | |
137 | + IPushedButton button = buttonDispatcher.get(hookId); | |
138 | + if (button != null) | |
139 | + { | |
140 | + // ボタンを押したことにする | |
141 | + ret = button.pushedButton(false); | |
142 | + //v.performClick(); // 本来はこっちで動かしたい。 | |
143 | + } | |
144 | + } | |
145 | + catch (Exception e) | |
146 | + { | |
147 | + e.printStackTrace(); | |
148 | + } | |
149 | + return (ret); | |
150 | + } | |
151 | + | |
152 | + // オートフォーカスエリアに含まれていた場合には、オートフォーカスを実行する | |
125 | 153 | return ((id == R.id.liveview)&&(dispatcher.dispatchAreaAction(event, ICameraFeatureDispatcher.FEATURE_AREA_ACTION_DRIVE_AUTOFOCUS))); |
126 | 154 | } |
127 | 155 | |
128 | 156 | /** |
157 | + * タッチエリアを確認しフックするかどうか確認する (0なら hook しない) | |
158 | + * | |
159 | + */ | |
160 | + private int checkHookTouchedPosition(View v, MotionEvent event) | |
161 | + { | |
162 | + int hookId = 0; | |
163 | + try | |
164 | + { | |
165 | + // オートフォーカスエリア内かどうかチェックする | |
166 | + if (dispatcher.dispatchAreaAction(event, ICameraFeatureDispatcher.FEATURE_AREA_ACTION_CHECK_CONTAINS_AUTOFOCUS_AREA)) | |
167 | + { | |
168 | + if (event.getAction() != MotionEvent.ACTION_DOWN) | |
169 | + { | |
170 | + // オートフォーカスエリア内のときには、ACTION_DOWN のみを拾う | |
171 | + return (R.id.liveview); | |
172 | + } | |
173 | + // オートフォーカスエリアに含まれているのでオートフォーカスする | |
174 | + return (0); | |
175 | + } | |
176 | + if (event.getAction() != MotionEvent.ACTION_UP) | |
177 | + { | |
178 | + // オートフォーカスエリア外のときには、 ACTION_UP のみを拾う | |
179 | + return (R.id.liveview); | |
180 | + } | |
181 | + | |
182 | + // オートフォーカスエリア外なので、イベントをフックしてボタン操作に変える(当面は右下のみ) | |
183 | + float areaY = event.getY() / v.getHeight(); | |
184 | + float areaX = event.getX() / v.getWidth(); | |
185 | + Log.v(TAG, "HOOKED POSITION (areaX : " + areaX + " areaY : " + areaY + ")"); | |
186 | + if (areaY > 0.66f) | |
187 | + { | |
188 | + if (areaX > 0.8333f) | |
189 | + { | |
190 | + // 画面右下のオートフォーカスエリア外のときのみ、撮影ボタンを押したことにする | |
191 | + // (0.66f ... 画面タッチエリアの下 1/3、0.8333f ... 画面タッチエリアの右側 1/6) | |
192 | + return (R.id.btn_6); | |
193 | + } | |
194 | + else if (areaX < 0.1666f) | |
195 | + { | |
196 | + return (R.id.btn_1); | |
197 | + } | |
198 | + } | |
199 | + } | |
200 | + catch (Exception e) | |
201 | + { | |
202 | + // ちゃんとポジションが取れなかった... | |
203 | + e.printStackTrace(); | |
204 | + hookId = 0; | |
205 | + } | |
206 | + return (hookId); | |
207 | + } | |
208 | + | |
209 | + /** | |
129 | 210 | * 操作の可否を設定する。 |
130 | 211 | * |
131 | 212 | */ |
@@ -27,6 +27,9 @@ public interface IOlyCameraCoordinator | ||
27 | 27 | boolean driveAutoFocus(MotionEvent event); |
28 | 28 | void unlockAutoFocus(); |
29 | 29 | |
30 | + /** ポイントがオートフォーカス可能なエリアかどうかチェックする **/ | |
31 | + boolean isContainsAutoFocusPoint(MotionEvent event); // trueならオートフォーカス可能 | |
32 | + | |
30 | 33 | /** シングル撮影機能の実行 **/ |
31 | 34 | void singleShot(); |
32 | 35 |
@@ -44,7 +44,7 @@ class LevelMeterHolder implements ILevelGauge | ||
44 | 44 | if (!isWatchingLevelGauge) |
45 | 45 | { |
46 | 46 | // レベルゲージの監視はしない |
47 | - Log.v(TAG, "checkLevelGauge() : not watch"); | |
47 | + // Log.v(TAG, "checkLevelGauge() : not watch"); // 結構ログが出るので消す | |
48 | 48 | return; |
49 | 49 | } |
50 | 50 | try |
@@ -2,6 +2,7 @@ package jp.sfjp.gokigen.a01c.olycamerawrapper; | ||
2 | 2 | |
3 | 3 | import android.app.Activity; |
4 | 4 | import android.graphics.PointF; |
5 | +import android.graphics.RectF; | |
5 | 6 | import android.util.Log; |
6 | 7 | import android.view.MotionEvent; |
7 | 8 | import android.widget.Toast; |
@@ -194,6 +195,36 @@ public class OlyCameraCoordinator implements IOlyCameraCoordinator, IIndicatorCo | ||
194 | 195 | } |
195 | 196 | |
196 | 197 | /** |
198 | + * オートフォーカスのポイントに含まれているか確認する (trueだったら含まれる) | |
199 | + * | |
200 | + */ | |
201 | + @Override | |
202 | + public boolean isContainsAutoFocusPoint(MotionEvent event) | |
203 | + { | |
204 | + //// 以下の機能は、タッチイベントの受信時のみ動作させる | |
205 | + //if (event.getAction() != MotionEvent.ACTION_DOWN) | |
206 | + //{ | |
207 | + // return (false); | |
208 | + //} | |
209 | + try | |
210 | + { | |
211 | + // タッチした位置を取得する | |
212 | + PointF point = focusFrameDisplay.getPointWithEvent(event); | |
213 | + | |
214 | + // AFの有効座標を取得する | |
215 | + RectF rect = camera.getAutoFocusEffectiveArea(); | |
216 | + //Log.v(TAG, "AF POINT (" + point.x + "," + point.y + ")"); | |
217 | + //Log.v(TAG, "AF EFFECTIVE AREA (" + rect.left + "," + rect.left + ") - (" + rect.right + "," + rect.bottom + ")"); | |
218 | + return (rect.contains(point.x, point.y)); | |
219 | + } | |
220 | + catch (Exception e) | |
221 | + { | |
222 | + e.printStackTrace(); | |
223 | + } | |
224 | + return (false); | |
225 | + } | |
226 | + | |
227 | + /** | |
197 | 228 | * フォーカスロックの解除 |
198 | 229 | */ |
199 | 230 | public void unlockAutoFocus() |
@@ -337,6 +337,11 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher | ||
337 | 337 | */ |
338 | 338 | break; |
339 | 339 | |
340 | + case ICameraFeatureDispatcher.FEATURE_AREA_ACTION_CHECK_CONTAINS_AUTOFOCUS_AREA: | |
341 | + // AUTOFOCUS エリアに含まれているかどうかチェックする | |
342 | + ret = camera.isContainsAutoFocusPoint(event); | |
343 | + break; | |
344 | + | |
340 | 345 | case FEATURE_AREA_ACTION_NONE: |
341 | 346 | default: |
342 | 347 | // 何もしない |
@@ -114,6 +114,9 @@ public interface ICameraFeatureDispatcher | ||
114 | 114 | int FEATURE_AREA_ACTION_NONE = 100; |
115 | 115 | int FEATURE_AREA_ACTION_NOT_CONNECTED = 101; |
116 | 116 | int FEATURE_AREA_ACTION_DRIVE_AUTOFOCUS = 102; |
117 | + int FEATURE_AREA_ACTION_CHECK_CONTAINS_AUTOFOCUS_AREA = 103; | |
118 | + | |
119 | + | |
117 | 120 | |
118 | 121 | // アクションインタフェース |
119 | 122 | String getTakeMode(); // 撮影モードの取得 |