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;
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);
}
}
/**
- * タッチエリアを確認しフックするかどうか確認する (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
{
// オートフォーカスエリア内かどうかチェックする
if (event.getAction() != MotionEvent.ACTION_DOWN)
{
// オートフォーカスエリア内のときには、ACTION_DOWN のみを拾う
- return (R.id.liveview);
+ return (R.id.button_area);
}
// オートフォーカスエリアに含まれているのでオートフォーカスする
return (0);
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)
{
{
// ちゃんとポジションが取れなかった...
e.printStackTrace();
- hookId = 0;
}
- return (hookId);
+ // エリア外だけれどもオートフォーカスする
+ return (0);
}
/**
public class PushedButtonFactory
{
- private final String TAG = toString();
-
+ //private final String TAG = toString();
private SparseArray<IPushedButton> buttonMap;
public PushedButtonFactory(Context context, ICameraFeatureDispatcher dispatcher)
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()
--- /dev/null
+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)));
+ }
+}
String ACTION_BUTTON4 = "B4";
String ACTION_BUTTON5 = "B5";
String ACTION_BUTTON6 = "B6";
+ String ACTION_BUTTONL = "LA";
// エリアアクション
String ACTION_AREA1 = "A1";
android:text="@string/app_name"
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/white"
android:clickable="true"
+ android:focusable="true"
android:textSize="12sp" />
<TextView
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: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" />
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>
android:text="@string/app_name"
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/white"
android:clickable="true"
+ android:focusable="true"
android:textSize="12sp" />
<TextView
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">
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
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"