OSDN Git Service

画面右下および左下のAF動作外のエリアをタッチしたときの標準処理を、ボタン6と等価にする。
authorMRSa <mrsa@myad.jp>
Wed, 31 Jan 2018 15:20:41 +0000 (00:20 +0900)
committerMRSa <mrsa@myad.jp>
Wed, 31 Jan 2018 15:20:41 +0000 (00:20 +0900)
wear/src/main/java/jp/sfjp/gokigen/a01c/IShowInformation.java
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/OlyCameraLiveViewOnTouchListener.java
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/button/PushedButtonFactory.java
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/button/PushedLowerArea.java [new file with mode: 0644]
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/dispatcher/ICameraFeatureDispatcher.java
wear/src/main/res/layout-notround/activity_main.xml
wear/src/main/res/layout-round/activity_main.xml

index 8cf6d11..ce662a6 100644 (file)
@@ -26,6 +26,7 @@ public interface IShowInformation
     int BUTTON_4 = 4;
     int BUTTON_5 = 5;
     int BUTTON_6 = 6;
+    int LOWER_AREA = 7;
 
     int VIBRATE_PATTERN_NONE  = 0;
     int VIBRATE_PATTERN_SIMPLE_SHORT  = 1;
index 98a39be..d395866 100644 (file)
@@ -127,24 +127,35 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
         if (hookId != 0)
         {
             boolean ret = false;
-            if (hookId == R.id.liveview)
+            if (hookId == R.id.button_area)
             {
                 //  何もしないパターン。。。
                 return (true);
             }
             try
             {
-                IPushedButton button = buttonDispatcher.get(hookId);
+                IPushedButton button = buttonDispatcher.get(R.id.liveview);
                 if (button != null)
                 {
-                    // ボタンを押したことにする
-                    ret = button.pushedButton(false);
+                    if (hookId == R.id.btn_1)
+                    {
+                        // 左側のエリア → 長押し
+                        ret = button.pushedButton(true);
+                    }
+                    else // (hookId == R.id.btn_6)
+                    {
+                        // 右側のエリア → クリック
+                        ret = button.pushedButton(false);
+                    }
+                    //// ボタンを押したことにする
+                    ////ret = button.pushedButton(false);
                     //v.performClick();  // 本来はこっちで動かしたい。
                 }
             }
             catch (Exception e)
             {
                 e.printStackTrace();
+                v.performClick(); // exception のときだけ...ダミー処理
             }
             return (ret);
         }
@@ -154,12 +165,12 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
     }
 
     /**
-     *   タッチエリアを確認しフックするかどうか確認する (0なら hook しない)
+     *   タッチエリアを確認しフックするかどうか確認する
+     *    (0なら hook しない, 左のエリアは、R.id.btn_1, 右のエリアは、R.id.btn_2, 何もしない場合は R.id.area)
      *
      */
     private int checkHookTouchedPosition(View v, MotionEvent event)
     {
-        int hookId = 0;
         try
         {
             // オートフォーカスエリア内かどうかチェックする
@@ -168,7 +179,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
                 if (event.getAction() != MotionEvent.ACTION_DOWN)
                 {
                     // オートフォーカスエリア内のときには、ACTION_DOWN のみを拾う
-                    return (R.id.liveview);
+                    return (R.id.button_area);
                 }
                 // オートフォーカスエリアに含まれているのでオートフォーカスする
                 return (0);
@@ -176,14 +187,14 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
             if (event.getAction() != MotionEvent.ACTION_UP)
             {
                 // オートフォーカスエリア外のときには、 ACTION_UP のみを拾う
-                return (R.id.liveview);
+                return (R.id.button_area);
             }
 
             // オートフォーカスエリア外なので、イベントをフックしてボタン操作に変える(当面は右下のみ)
             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 (areaY > 0.75f)
             {
                 if (areaX > 0.8333f)
                 {
@@ -201,9 +212,9 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
         {
             // ちゃんとポジションが取れなかった...
             e.printStackTrace();
-            hookId = 0;
         }
-        return (hookId);
+        // エリア外だけれどもオートフォーカスする
+        return (0);
     }
 
     /**
index 1a25ed3..01bb368 100644 (file)
@@ -8,8 +8,7 @@ import jp.sfjp.gokigen.a01c.olycamerawrapper.dispatcher.ICameraFeatureDispatcher
 
 public class PushedButtonFactory
 {
-    private final String TAG = toString();
-
+    //private final String TAG = toString();
     private SparseArray<IPushedButton> buttonMap;
 
     public PushedButtonFactory(Context context, ICameraFeatureDispatcher dispatcher)
@@ -25,6 +24,7 @@ public class PushedButtonFactory
         buttonMap.put(R.id.text_2, new PushedArea2(context, dispatcher));
         buttonMap.put(R.id.text_3, new PushedArea3(context, dispatcher));
         buttonMap.put(R.id.text_4, new PushedArea4(context, dispatcher));
+        buttonMap.put(R.id.liveview, new PushedLowerArea(context, dispatcher));
     }
 
     public SparseArray<IPushedButton> getButtonMap()
diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/button/PushedLowerArea.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/button/PushedLowerArea.java
new file mode 100644 (file)
index 0000000..f95fab6
--- /dev/null
@@ -0,0 +1,76 @@
+package jp.sfjp.gokigen.a01c.liveview.button;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.support.v7.preference.PreferenceManager;
+
+import jp.sfjp.gokigen.a01c.IShowInformation;
+import jp.sfjp.gokigen.a01c.olycamerawrapper.dispatcher.ICameraFeatureDispatcher;
+
+
+/**
+ *   ライブビュー画面のオートフォーカスエリア外のボタン操作
+ *
+ */
+class PushedLowerArea implements IPushedButton
+{
+    private final SharedPreferences preferences;
+    private final ICameraFeatureDispatcher dispatcher;
+
+    PushedLowerArea(Context context, ICameraFeatureDispatcher dispatcher)
+    {
+        preferences = PreferenceManager.getDefaultSharedPreferences(context);
+        this.dispatcher = dispatcher;
+    }
+
+    @Override
+    public boolean pushedButton(boolean isLongClick)
+    {
+        int defaultAction;   // = ICameraFeatureDispatcher.FEATURE_SHUTTER_SINGLESHOT;
+        String preference_action_id = ICameraFeatureDispatcher.ACTION_BUTTONL;
+        if (isLongClick)
+        {
+            preference_action_id = preference_action_id + ICameraFeatureDispatcher.ACTION_SECOND_CHOICE;
+        }
+        String takeMode = dispatcher.getTakeMode();
+        switch (takeMode)
+        {
+            case "P":
+                preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_P;
+                defaultAction =  (isLongClick) ? ICameraFeatureDispatcher.FEATURE_SHOT_BRACKET_EXPOSURE : ICameraFeatureDispatcher.FEATURE_SHUTTER_SINGLESHOT;
+                break;
+
+            case "A":
+                preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_A;
+                defaultAction =  (isLongClick) ? ICameraFeatureDispatcher.FEATURE_SHOT_BRACKET_APERATURE : ICameraFeatureDispatcher.FEATURE_SHUTTER_SINGLESHOT;
+                break;
+
+            case "S":
+                preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_S;
+                defaultAction =  (isLongClick) ? ICameraFeatureDispatcher.FEATURE_SHOT_BRACKET_SHUTTER : ICameraFeatureDispatcher.FEATURE_SHUTTER_SINGLESHOT;
+                break;
+
+            case "M":
+                preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_M;
+                defaultAction =  (isLongClick) ? ICameraFeatureDispatcher.FEATURE_SHOT_BRACKET_WB : ICameraFeatureDispatcher.FEATURE_SHUTTER_SINGLESHOT;
+                break;
+
+            case "ART":
+                preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_ART;
+                defaultAction =  (isLongClick) ? ICameraFeatureDispatcher.FEATURE_SHOT_BRACKET_ART_FILTER : ICameraFeatureDispatcher.FEATURE_SHUTTER_SINGLESHOT;
+                break;
+
+            case "Movie":
+                preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_MOVIE;
+                defaultAction = ICameraFeatureDispatcher.FEATURE_CONTROL_MOVIE;
+                break;
+
+            case "iAuto":
+            default:
+                preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_IAUTO;
+                defaultAction =  (isLongClick) ? ICameraFeatureDispatcher.FEATURE_SHOT_INTERVAL_5SEC : ICameraFeatureDispatcher.FEATURE_SHUTTER_SINGLESHOT;
+                break;
+        }
+        return (dispatcher.dispatchAction(IShowInformation.LOWER_AREA, preferences.getInt(preference_action_id, defaultAction)));
+    }
+}
index 4066051..7364764 100644 (file)
@@ -24,6 +24,7 @@ public interface ICameraFeatureDispatcher
     String ACTION_BUTTON4 = "B4";
     String ACTION_BUTTON5 = "B5";
     String ACTION_BUTTON6 = "B6";
+    String ACTION_BUTTONL = "LA";
 
     // エリアアクション
     String ACTION_AREA1 = "A1";
index ee89a2a..8649117 100644 (file)
@@ -35,6 +35,7 @@
                 android:text="@string/app_name"
                 android:textColor="@android:color/white"
                 android:clickable="true"
+                android:focusable="true"
                 android:textSize="12sp" />
 
             <TextView
@@ -45,6 +46,7 @@
                 android:text="@string/text_message_blank"
                 android:textColor="@android:color/white"
                 android:clickable="true"
+                android:focusable="true"
                 android:textSize="12sp" />
 
             <TextView
@@ -55,6 +57,7 @@
                 android:text="@string/text_message_blank"
                 android:textColor="@android:color/white"
                 android:clickable="true"
+                android:focusable="true"
                 android:textSize="12sp" />
 
             <TextView
                 android:text="@string/text_message_blank"
                 android:textColor="@android:color/holo_orange_light"
                 android:clickable="true"
+                android:focusable="true"
                 android:textSize="12sp" />
         </LinearLayout>
 
         <LinearLayout
+            android:id="@+id/button_area"
             android:layout_width="match_parent"
             android:layout_height="match_parent">
 
@@ -79,6 +84,7 @@
                 android:layout_gravity="bottom"
                 android:background="@null"
                 android:clickable="true"
+                android:focusable="true"
                 android:contentDescription="@string/description_control_button"
                 android:src="@drawable/btn_ic_grid_off" />
 
@@ -89,6 +95,7 @@
                 android:layout_gravity="bottom"
                 android:background="@null"
                 android:clickable="true"
+                android:focusable="true"
                 android:contentDescription="@string/description_control_button"
                 android:src="@drawable/btn_ic_remove_circle_outline" />
 
                 android:layout_gravity="bottom"
                 android:background="@null"
                 android:clickable="true"
+                android:focusable="true"
                 android:contentDescription="@string/description_control_button"
                 android:src="@drawable/btn_ic_add_circle_outline" />
 
                 android:layout_gravity="bottom"
                 android:background="@null"
                 android:clickable="true"
+                android:focusable="true"
                 android:contentDescription="@string/description_control_button"
                 android:src="@drawable/btn_ic_remove_circle" />
 
                 android:layout_gravity="bottom"
                 android:background="@null"
                 android:clickable="true"
+                android:focusable="true"
                 android:contentDescription="@string/description_control_button"
                 android:src="@drawable/btn_ic_add_circle" />
 
                 android:layout_gravity="bottom"
                 android:background="@null"
                 android:clickable="true"
+                android:focusable="true"
                 android:contentDescription="@string/description_control_button"
                 android:src="@drawable/btn_ic_camera_alt" />
         </LinearLayout>
index 189f35f..5499921 100644 (file)
@@ -35,6 +35,7 @@
                 android:text="@string/app_name"
                 android:textColor="@android:color/white"
                 android:clickable="true"
+                android:focusable="true"
                 android:textSize="12sp" />
 
             <TextView
@@ -45,6 +46,7 @@
                 android:text="@string/text_message_blank"
                 android:textColor="@android:color/white"
                 android:clickable="true"
+                android:focusable="true"
                 android:textSize="12sp" />
 
             <TextView
@@ -55,6 +57,7 @@
                 android:text="@string/text_message_blank"
                 android:textColor="@android:color/white"
                 android:clickable="true"
+                android:focusable="true"
                 android:textSize="12sp" />
 
             <TextView
                 android:text="@string/text_message_blank"
                 android:textColor="@android:color/holo_orange_light"
                 android:clickable="true"
+                android:focusable="true"
                 android:textSize="12sp" />
         </LinearLayout>
 
         <LinearLayout
+            android:id="@+id/button_area"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:orientation="horizontal">
@@ -79,6 +84,7 @@
                 android:layout_height="15dp"
                 android:layout_width="25dp"
                 android:clickable="true"
+                android:focusable="true"
                 android:contentDescription="@string/description_control_button"
                 android:src="@drawable/btn_ic_grid_off" />
             <ImageButton
@@ -88,6 +94,7 @@
                 android:layout_height="15dp"
                 android:layout_width="25dp"
                 android:clickable="true"
+                android:focusable="true"
                 android:contentDescription="@string/description_control_button"
                 android:src="@drawable/btn_ic_remove_circle_outline" />
             <ImageButton
                 android:layout_height="15dp"
                 android:layout_width="25dp"
                 android:clickable="true"
+                android:focusable="true"
                 android:contentDescription="@string/description_control_button"
                 android:src="@drawable/btn_ic_add_circle_outline" />
             <ImageButton
                 android:layout_height="15dp"
                 android:layout_width="25dp"
                 android:clickable="true"
+                android:focusable="true"
                 android:contentDescription="@string/description_control_button"
                 android:src="@drawable/btn_ic_remove_circle" />
             <ImageButton
                 android:layout_width="25dp"
                 android:layout_height="15dp"
                 android:clickable="true"
+                android:focusable="true"
                 android:layout_gravity="bottom"
                 android:background="@null"
                 android:contentDescription="@string/description_control_button"
                 android:layout_width="25dp"
                 android:layout_height="15dp"
                 android:clickable="true"
+                android:focusable="true"
                 android:layout_gravity="bottom"
                 android:background="@null"
                 android:contentDescription="@string/description_control_button"