OSDN Git Service

画面右下および左下のAF動作外のエリアをタッチしたときにボタンアクションを実行できるようにする。(暫定)
authorMRSa <mrsa@myad.jp>
Mon, 29 Jan 2018 15:27:23 +0000 (00:27 +0900)
committerMRSa <mrsa@myad.jp>
Mon, 29 Jan 2018 15:27:23 +0000 (00:27 +0900)
app/build.gradle
build.gradle
wear/build.gradle
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/OlyCameraLiveViewOnTouchListener.java
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/IOlyCameraCoordinator.java
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/LevelMeterHolder.java
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/OlyCameraCoordinator.java
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/dispatcher/FeatureDispatcher.java
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/dispatcher/ICameraFeatureDispatcher.java

index 830e99e..b643fb1 100644 (file)
@@ -32,15 +32,15 @@ android {
 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     wearApp project(path: ':wear')
-    provided 'com.google.android.wearable:wearable:2.1.0'
-    compile 'com.google.android.support:wearable:2.1.0'
-    compile 'com.google.android.gms:play-services-wearable:11.4.2'
+    provided 'com.google.android.wearable:wearable:2.2.0'
+    compile 'com.google.android.support:wearable:2.2.0'
+    compile 'com.google.android.gms:play-services-wearable:11.8.0'
 
-    compile 'com.android.support:animated-vector-drawable:27.0.0'
-    compile 'com.android.support:percent:27.0.0'
-    compile 'com.android.support:support-vector-drawable:27.0.0'
-    compile 'com.android.support:appcompat-v7:27.0.0'
-    compile 'com.android.support:preference-v7:27.0.0'
-    compile 'com.android.support:exifinterface:27.0.0'
-    compile 'com.android.support:support-v4:27.0.0'
+    compile 'com.android.support:animated-vector-drawable:27.0.2'
+    compile 'com.android.support:percent:27.0.2'
+    compile 'com.android.support:support-vector-drawable:27.0.2'
+    compile 'com.android.support:appcompat-v7:27.0.2'
+    compile 'com.android.support:preference-v7:27.0.2'
+    compile 'com.android.support:exifinterface:27.0.2'
+    compile 'com.android.support:support-v4:27.0.2'
 }
index 5f57b73..b3b1258 100644 (file)
@@ -5,7 +5,7 @@ buildscript {
         jcenter()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:3.0.0'
+        classpath 'com.android.tools.build:gradle:3.0.1'
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
index 82da714..ac57b7c 100644 (file)
@@ -21,17 +21,17 @@ android {
 dependencies {
     compile fileTree(include: ['*.jar'], dir: 'libs')
 
-    provided 'com.google.android.wearable:wearable:2.1.0'
-    compile 'com.google.android.support:wearable:2.1.0'
-    compile 'com.google.android.gms:play-services-wearable:11.4.2'
+    provided 'com.google.android.wearable:wearable:2.2.0'
+    compile 'com.google.android.support:wearable:2.2.0'
+    compile 'com.google.android.gms:play-services-wearable:11.8.0'
 
     //compile 'com.android.support:wear:26.0.0'
-    compile 'com.android.support:animated-vector-drawable:27.0.0'
-    compile 'com.android.support:percent:27.0.0'
-    compile 'com.android.support:support-vector-drawable:27.0.0'
-    compile 'com.android.support:appcompat-v7:27.0.0'
-    compile 'com.android.support:preference-v7:27.0.0'
-    compile 'com.android.support:exifinterface:27.0.0'
-    compile 'com.android.support:support-v4:27.0.0'
+    compile 'com.android.support:animated-vector-drawable:27.0.2'
+    compile 'com.android.support:percent:27.0.2'
+    compile 'com.android.support:support-vector-drawable:27.0.2'
+    compile 'com.android.support:appcompat-v7:27.0.2'
+    compile 'com.android.support:preference-v7:27.0.2'
+    compile 'com.android.support:exifinterface:27.0.2'
+    compile 'com.android.support:support-v4:27.0.2'
     compile files('libs/olycamerakit.jar')
 }
index 0bfd66d..98a39be 100644 (file)
@@ -121,11 +121,92 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
             Log.v(TAG, "onTouch() : prohibit operation");
             return ((operationMode == IShowInformation.operation.ONLY_CONNECT)&&(changeScene.showConnectionStatus()));
         }
-        // 現在のところ、タッチエリアの場合はオートフォーカス実行で固定
+
+        // 画面下部のエリア(オートフォーカスエリア外)をタッチした場合には、ボタン押下アクションに切り替える
+        int hookId = checkHookTouchedPosition(v, event);
+        if (hookId != 0)
+        {
+            boolean ret = false;
+            if (hookId == R.id.liveview)
+            {
+                //  何もしないパターン。。。
+                return (true);
+            }
+            try
+            {
+                IPushedButton button = buttonDispatcher.get(hookId);
+                if (button != null)
+                {
+                    // ボタンを押したことにする
+                    ret = button.pushedButton(false);
+                    //v.performClick();  // 本来はこっちで動かしたい。
+                }
+            }
+            catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+            return (ret);
+        }
+
+        // オートフォーカスエリアに含まれていた場合には、オートフォーカスを実行する
         return ((id == R.id.liveview)&&(dispatcher.dispatchAreaAction(event, ICameraFeatureDispatcher.FEATURE_AREA_ACTION_DRIVE_AUTOFOCUS)));
     }
 
     /**
+     *   タッチエリアを確認しフックするかどうか確認する (0なら hook しない)
+     *
+     */
+    private int checkHookTouchedPosition(View v, MotionEvent event)
+    {
+        int hookId = 0;
+        try
+        {
+            // オートフォーカスエリア内かどうかチェックする
+            if (dispatcher.dispatchAreaAction(event, ICameraFeatureDispatcher.FEATURE_AREA_ACTION_CHECK_CONTAINS_AUTOFOCUS_AREA))
+            {
+                if (event.getAction() != MotionEvent.ACTION_DOWN)
+                {
+                    // オートフォーカスエリア内のときには、ACTION_DOWN のみを拾う
+                    return (R.id.liveview);
+                }
+                // オートフォーカスエリアに含まれているのでオートフォーカスする
+                return (0);
+            }
+            if (event.getAction() != MotionEvent.ACTION_UP)
+            {
+                // オートフォーカスエリア外のときには、 ACTION_UP のみを拾う
+                return (R.id.liveview);
+            }
+
+            // オートフォーカスエリア外なので、イベントをフックしてボタン操作に変える(当面は右下のみ)
+            float areaY = event.getY() / v.getHeight();
+            float areaX = event.getX() / v.getWidth();
+            Log.v(TAG, "HOOKED POSITION (areaX : " + areaX + " areaY : " + areaY + ")");
+            if (areaY > 0.66f)
+            {
+                if (areaX > 0.8333f)
+                {
+                    // 画面右下のオートフォーカスエリア外のときのみ、撮影ボタンを押したことにする
+                    // (0.66f ... 画面タッチエリアの下 1/3、0.8333f ... 画面タッチエリアの右側 1/6)
+                    return (R.id.btn_6);
+                }
+                else if (areaX < 0.1666f)
+                {
+                    return (R.id.btn_1);
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            // ちゃんとポジションが取れなかった...
+            e.printStackTrace();
+            hookId = 0;
+        }
+        return (hookId);
+    }
+
+    /**
      *   操作の可否を設定する。
      *
      */
index 0b3011a..88e4138 100644 (file)
@@ -27,6 +27,9 @@ public interface IOlyCameraCoordinator
     boolean driveAutoFocus(MotionEvent event);
     void unlockAutoFocus();
 
+    /** ポイントがオートフォーカス可能なエリアかどうかチェックする **/
+    boolean isContainsAutoFocusPoint(MotionEvent event);  // trueならオートフォーカス可能
+
     /** シングル撮影機能の実行 **/
     void singleShot();
 
index 868c559..930fdf1 100644 (file)
@@ -44,7 +44,7 @@ class LevelMeterHolder implements ILevelGauge
         if (!isWatchingLevelGauge)
         {
             // レベルゲージの監視はしない
-            Log.v(TAG, "checkLevelGauge() : not watch");
+            // Log.v(TAG, "checkLevelGauge() : not watch");  // 結構ログが出るので消す
             return;
         }
         try
index 7d2a35f..bfe9f8e 100644 (file)
@@ -2,6 +2,7 @@ package jp.sfjp.gokigen.a01c.olycamerawrapper;
 
 import android.app.Activity;
 import android.graphics.PointF;
+import android.graphics.RectF;
 import android.util.Log;
 import android.view.MotionEvent;
 import android.widget.Toast;
@@ -194,6 +195,36 @@ public class OlyCameraCoordinator implements IOlyCameraCoordinator, IIndicatorCo
     }
 
     /**
+     *   オートフォーカスのポイントに含まれているか確認する (trueだったら含まれる)
+     *
+     */
+    @Override
+    public boolean isContainsAutoFocusPoint(MotionEvent event)
+    {
+        //// 以下の機能は、タッチイベントの受信時のみ動作させる
+        //if (event.getAction() != MotionEvent.ACTION_DOWN)
+        //{
+        //    return (false);
+        //}
+        try
+        {
+            // タッチした位置を取得する
+            PointF point = focusFrameDisplay.getPointWithEvent(event);
+
+            // AFの有効座標を取得する
+            RectF rect = camera.getAutoFocusEffectiveArea();
+            //Log.v(TAG, "AF POINT (" + point.x + "," + point.y + ")");
+            //Log.v(TAG, "AF EFFECTIVE AREA (" + rect.left + "," + rect.left + ") - (" + rect.right + "," + rect.bottom + ")");
+            return (rect.contains(point.x, point.y));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    /**
      *   フォーカスロックの解除
      */
     public void unlockAutoFocus()
index e002387..dd196f4 100644 (file)
@@ -337,6 +337,11 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
                 */
                 break;
 
+            case ICameraFeatureDispatcher.FEATURE_AREA_ACTION_CHECK_CONTAINS_AUTOFOCUS_AREA:
+                // AUTOFOCUS エリアに含まれているかどうかチェックする
+                ret = camera.isContainsAutoFocusPoint(event);
+                break;
+
             case FEATURE_AREA_ACTION_NONE:
             default:
                 // 何もしない
index 9a02838..4066051 100644 (file)
@@ -114,6 +114,9 @@ public interface ICameraFeatureDispatcher
     int FEATURE_AREA_ACTION_NONE = 100;
     int FEATURE_AREA_ACTION_NOT_CONNECTED = 101;
     int FEATURE_AREA_ACTION_DRIVE_AUTOFOCUS = 102;
+    int FEATURE_AREA_ACTION_CHECK_CONTAINS_AUTOFOCUS_AREA = 103;
+
+
 
     // アクションインタフェース
     String getTakeMode();   // 撮影モードの取得