From: MRSa Date: Wed, 31 Jan 2018 15:20:41 +0000 (+0900) Subject: 画面右下および左下のAF動作外のエリアをタッチしたときの標準処理を、ボタン6と等価にする。 X-Git-Tag: V130~6 X-Git-Url: http://git.osdn.net/view?p=gokigen%2FA01c.git;a=commitdiff_plain;h=423e56a61a857d3a40f0c7dc1ddf40b4adc7d863 画面右下および左下のAF動作外のエリアをタッチしたときの標準処理を、ボタン6と等価にする。 --- diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/IShowInformation.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/IShowInformation.java index 8cf6d11..ce662a6 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/IShowInformation.java +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/IShowInformation.java @@ -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; diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/OlyCameraLiveViewOnTouchListener.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/OlyCameraLiveViewOnTouchListener.java index 98a39be..d395866 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/OlyCameraLiveViewOnTouchListener.java +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/OlyCameraLiveViewOnTouchListener.java @@ -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); } /** diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/button/PushedButtonFactory.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/button/PushedButtonFactory.java index 1a25ed3..01bb368 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/button/PushedButtonFactory.java +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/button/PushedButtonFactory.java @@ -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 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 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 index 0000000..f95fab6 --- /dev/null +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/button/PushedLowerArea.java @@ -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))); + } +} diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/dispatcher/ICameraFeatureDispatcher.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/dispatcher/ICameraFeatureDispatcher.java index 4066051..7364764 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/dispatcher/ICameraFeatureDispatcher.java +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/dispatcher/ICameraFeatureDispatcher.java @@ -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"; diff --git a/wear/src/main/res/layout-notround/activity_main.xml b/wear/src/main/res/layout-notround/activity_main.xml index ee89a2a..8649117 100644 --- a/wear/src/main/res/layout-notround/activity_main.xml +++ b/wear/src/main/res/layout-notround/activity_main.xml @@ -35,6 +35,7 @@ android:text="@string/app_name" android:textColor="@android:color/white" android:clickable="true" + android:focusable="true" android:textSize="12sp" /> @@ -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" /> @@ -99,6 +106,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_add_circle_outline" /> @@ -109,6 +117,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" /> @@ -119,6 +128,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_add_circle" /> @@ -129,6 +139,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_camera_alt" /> diff --git a/wear/src/main/res/layout-round/activity_main.xml b/wear/src/main/res/layout-round/activity_main.xml index 189f35f..5499921 100644 --- a/wear/src/main/res/layout-round/activity_main.xml +++ b/wear/src/main/res/layout-round/activity_main.xml @@ -35,6 +35,7 @@ android:text="@string/app_name" android:textColor="@android:color/white" android:clickable="true" + android:focusable="true" android:textSize="12sp" /> @@ -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" />