OSDN Git Service

Greenボタンぽい処理を入れてみた。(OPC機では、お気に入り設定の記憶と呼び出しボタンになる。)
authorMRSa <mrsa@myad.jp>
Fri, 7 Sep 2018 14:14:26 +0000 (23:14 +0900)
committerMRSa <mrsa@myad.jp>
Fri, 7 Sep 2018 14:14:26 +0000 (23:14 +0900)
app/src/main/java/net/osdn/gokigen/gr2control/camera/ICameraButtonControl.java
app/src/main/java/net/osdn/gokigen/gr2control/camera/olympus/myolycameraprops/LoadSaveMyCameraPropertyDialog.java
app/src/main/java/net/osdn/gokigen/gr2control/camera/ricohgr2/operation/RicohGr2CameraButtonControl.java
app/src/main/java/net/osdn/gokigen/gr2control/liveview/LiveViewClickTouchListener.java
app/src/main/java/net/osdn/gokigen/gr2control/liveview/LiveViewFragment.java
app/src/main/res/layout-land/fragment_live_view.xml
app/src/main/res/layout/fragment_live_view.xml

index 817546a..9ce09d9 100644 (file)
@@ -4,6 +4,7 @@ public interface ICameraButtonControl
 {
     void pushedButton(String code);
 
+    String SPECIAL_GREEN_BUTTON = "btn_green";
 
     String FRONT_LEFT = "bjogleft";
     String FRONT_RIGHT = "bjogright";
index 7124694..3688d80 100644 (file)
@@ -22,7 +22,14 @@ public class LoadSaveMyCameraPropertyDialog extends DialogFragment implements Ta
     private FragmentTabHost tabHost = null;
     private ViewPager viewPager = null;
 
-    public void setPropertyOperationsHolder(ILoadSaveCameraProperties holder)
+    public static LoadSaveMyCameraPropertyDialog newInstance(ILoadSaveCameraProperties holder)
+    {
+        LoadSaveMyCameraPropertyDialog instance = new LoadSaveMyCameraPropertyDialog();
+        instance.setPropertyOperationsHolder(holder);
+        return (instance);
+    }
+
+    private void setPropertyOperationsHolder(ILoadSaveCameraProperties holder)
     {
         propertyOperations = holder;
     }
index c2eb2f1..4dc7c31 100644 (file)
@@ -14,6 +14,7 @@ public class RicohGr2CameraButtonControl implements ICameraButtonControl
 {
     private final String TAG = toString();
     private final String buttonControlUrl = "http://192.168.0.1/_gr";
+    private final String greenButtonUrl = "http://192.168.0.1/v1/params/camera";
     private int timeoutMs = 6000;
 
     /**
@@ -33,6 +34,12 @@ public class RicohGr2CameraButtonControl implements ICameraButtonControl
     private void pushButton(@NonNull final String keyName)
     {
         Log.v(TAG, "pushButton()");
+        if (keyName.equals(ICameraButtonControl.SPECIAL_GREEN_BUTTON))
+        {
+            // Greenボタンの処理を入れる
+            processGreenButton();
+            return;
+        }
         try
         {
             Thread thread = new Thread(new Runnable()
@@ -67,4 +74,42 @@ public class RicohGr2CameraButtonControl implements ICameraButtonControl
             e.printStackTrace();
         }
     }
+
+    private void processGreenButton()
+    {
+        Log.v(TAG, "processGreenButton()");
+        try
+        {
+            Thread thread = new Thread(new Runnable()
+            {
+                /**
+                 *
+                 *
+                 */
+                @Override
+                public void run()
+                {
+                    try
+                    {
+                        String cmd = "";
+                        String result = SimpleHttpClient.httpPut(greenButtonUrl, cmd, timeoutMs);
+                        if ((result == null)||(result.length() < 1)) {
+                            Log.v(TAG, "processGreenButton() reply is null.");
+                        } else {
+                            Log.v(TAG, "processGreenButton() result: " + result);
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
 }
index a1bfca3..257eb4a 100644 (file)
@@ -10,6 +10,7 @@ import android.view.View;
 import android.widget.Toast;
 
 import net.osdn.gokigen.gr2control.R;
+import net.osdn.gokigen.gr2control.camera.ICameraButtonControl;
 import net.osdn.gokigen.gr2control.camera.ICameraConnection;
 import net.osdn.gokigen.gr2control.camera.ICaptureControl;
 import net.osdn.gokigen.gr2control.camera.IFocusingControl;
@@ -131,6 +132,10 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
                     // ズームアウトのボタンが押された
                     actionZoomout();
                     break;
+                case R.id.specialButtonImageView:
+                    // スペシャルボタンが押された
+                    pushedSpecialButton();
+                    break;
 /*
                 case R.id.camera_property_settings_button:
                     // カメラのプロパティ設定
@@ -317,6 +322,15 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
     }
 
     /**
+     *   スペシャルボタンが押された時の処理
+     *
+     */
+    private void pushedSpecialButton()
+    {
+        showFavoriteDialog();
+    }
+
+    /**
      *   お気に入り設定ダイアログの表示
      *
      */
@@ -325,17 +339,25 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
         Log.v(TAG, "showFavoriteDialog()");
         try
         {
-            if (interfaceProvider.getCammeraConnectionMethod() != ICameraConnection.CameraConnectionMethod.OPC)
+            if (cameraConnection.getConnectionStatus() != ICameraConnection.CameraConnectionStatus.CONNECTED)
             {
-                // OPCカメラでない場合には、「OPCカメラのみ有効です」表示をして画面遷移させない
-                Toast.makeText(context, context.getText(R.string.only_opc_feature), Toast.LENGTH_SHORT).show();
+                // カメラと接続されていない時には、何もしない
                 return;
             }
 
-            if (cameraConnection.getConnectionStatus() == ICameraConnection.CameraConnectionStatus.CONNECTED)
+            if (interfaceProvider.getCammeraConnectionMethod() == ICameraConnection.CameraConnectionMethod.OPC)
             {
-                //  お気に入り設定のダイアログを表示する
+                //  OPCカメラの場合には、お気に入り設定のダイアログを表示する
                 dialogKicker.showFavoriteSettingDialog();
+                return;
+            }
+
+
+            ICameraButtonControl btnCtl = interfaceProvider.getButtonControl();
+            if (btnCtl != null)
+            {
+                // 'GREEN' ボタンが押されたこととする
+                btnCtl.pushedButton(ICameraButtonControl.SPECIAL_GREEN_BUTTON);
             }
         }
         catch (Exception e)
index 97bf434..569ebf7 100644 (file)
@@ -9,6 +9,7 @@ import android.os.Bundle;
 import android.os.Vibrator;
 import android.support.annotation.NonNull;
 import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
 import android.support.v4.content.ContextCompat;
 import android.support.v4.content.res.ResourcesCompat;
 import android.support.v4.graphics.drawable.DrawableCompat;
@@ -35,6 +36,8 @@ import net.osdn.gokigen.gr2control.camera.IFocusingModeNotify;
 import net.osdn.gokigen.gr2control.camera.IInterfaceProvider;
 import net.osdn.gokigen.gr2control.camera.ILiveViewControl;
 import net.osdn.gokigen.gr2control.camera.IZoomLensControl;
+import net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops.LoadSaveCameraProperties;
+import net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops.LoadSaveMyCameraPropertyDialog;
 import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
 import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
 import net.osdn.gokigen.gr2control.scene.IChangeScene;
@@ -171,6 +174,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             setOnClickListener(view, R.id.show_hide_grid_button);
             setOnClickListener(view, R.id.zoom_in_button);
             setOnClickListener(view, R.id.zoom_out_button);
+            setOnClickListener(view, R.id.specialButtonImageView);
 
             if (onPanelClickListener == null)
             {
@@ -633,16 +637,8 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
         try
         {
             Log.v(TAG, "showFavoriteSettingDialog()");
-/*
-            LoadSaveMyCameraPropertyDialog dialog = new LoadSaveMyCameraPropertyDialog();
-            dialog.setTargetFragment(this, COMMAND_MY_PROPERTY);
-            dialog.setPropertyOperationsHolder(new LoadSaveCameraProperties(getActivity(), interfaceProvider.getOlympusInterface()));
-            FragmentManager manager = getFragmentManager();
-            if (manager != null)
-            {
-                dialog.show(manager, "my_dialog");
-            }
-*/
+            LoadSaveMyCameraPropertyDialog dialog = LoadSaveMyCameraPropertyDialog.newInstance(new LoadSaveCameraProperties(getActivity(), interfaceProvider.getOlympusInterfaceProvider()));
+            dialog.show(getChildFragmentManager(), "favorite_dialog");
         }
         catch (Exception e)
         {
index b99ea55..3401344 100644 (file)
                 android:visibility="visible" />
 
             <ImageView
+                android:id="@+id/specialButtonImageView"
+                android:layout_width="match_parent"
+                android:layout_height="24dp"
+                android:layout_above="@id/show_hide_grid_button"
+                android:layout_alignParentLeft="true"
+                android:layout_alignParentStart="true"
+                android:scaleType="fitCenter"
+                android:clickable="true"
+                android:focusable="true"
+                android:visibility="visible"
+                android:src="@drawable/ic_check_box_black_24dp"
+                android:layout_marginBottom="14dp"
+                android:gravity="center" />
+
+            <ImageView
                 android:id="@+id/zoom_in_button"
                 android:layout_width="match_parent"
                 android:layout_height="24dp"
                 android:layout_height="24dp"
                 android:layout_alignParentStart="true"
                 android:layout_alignParentLeft="true"
-                android:layout_above="@id/show_hide_grid_button"
+                android:layout_above="@id/specialButtonImageView"
                 android:layout_marginBottom="16dp"
                 android:clickable="true"
                 android:focusable="true"
                 android:scaleType="fitCenter"
                 android:src="@drawable/ic_remove_circle_outline_black_24dp"
                 android:visibility="invisible" />
-
         </RelativeLayout>
 
         <view
index 37c3a30..0b720d0 100644 (file)
                 android:id="@+id/area_spacer01"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:layout_weight="2"
-                android:clickable="true"
-                android:focusable="true"
-                android:gravity="center"
-                android:scaleType="fitCenter"
-                android:visibility="invisible" />
-
-            <ImageView
-                android:id="@+id/area_spacer02"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:layout_weight="2"
+                android:layout_weight="1"
                 android:clickable="true"
                 android:focusable="true"
                 android:gravity="center"
                 android:id="@+id/area_spacer03"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:layout_weight="2"
+                android:layout_weight="1"
                 android:clickable="true"
                 android:focusable="true"
                 android:gravity="center"
                 android:id="@+id/area_spacer04"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:layout_weight="2"
+                android:layout_weight="1"
                 android:clickable="true"
                 android:focusable="true"
                 android:gravity="center"
                 android:visibility="invisible" />
 
             <ImageView
-                android:id="@+id/area_spacer05"
+                android:id="@+id/focusUnlockImageView"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:layout_weight="2"
-                android:clickable="true"
-                android:focusable="true"
-                android:gravity="center"
+                android:layout_weight="1"
                 android:scaleType="fitCenter"
-                android:visibility="invisible" />
-
-            <ImageView
-                android:id="@+id/area_spacer06"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:layout_weight="2"
                 android:clickable="true"
                 android:focusable="true"
-                android:gravity="center"
-                android:scaleType="fitCenter"
-                android:visibility="invisible" />
+                android:visibility="visible"
+                android:src="@drawable/ic_focus_free_black_24dp"
+                android:layout_marginBottom="10dp"
+                android:gravity="center" />
 
             <ImageView
-                android:id="@+id/focusUnlockImageView"
+                android:id="@+id/specialButtonImageView"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:layout_weight="1"
                 android:clickable="true"
                 android:focusable="true"
                 android:visibility="visible"
-                android:src="@drawable/ic_focus_free_black_24dp"
+                android:src="@drawable/ic_check_box_black_24dp"
                 android:layout_marginBottom="10dp"
                 android:gravity="center" />
         </LinearLayout>