OSDN Git Service

Zoomレンズ対応。
authorMRSa <mrsa@myad.jp>
Sun, 19 Aug 2018 13:42:30 +0000 (22:42 +0900)
committerMRSa <mrsa@myad.jp>
Sun, 19 Aug 2018 13:42:30 +0000 (22:42 +0900)
app/src/main/java/net/osdn/gokigen/gr2control/camera/olympus/wrapper/OlyCameraStatusWrapper.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/java/net/osdn/gokigen/gr2control/preference/olympus/PreferenceFragment.java
app/src/main/res/layout-land/fragment_live_view.xml
app/src/main/res/layout/fragment_live_view.xml
app/src/main/res/values-ja/strings.xml

index 9b93e7b..3610fc9 100644 (file)
@@ -8,7 +8,9 @@ import net.osdn.gokigen.gr2control.camera.ICameraStatusWatcher;
 import net.osdn.gokigen.gr2control.liveview.ICameraStatusUpdateNotify;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import jp.co.olympus.camerakit.OLYCamera;
 import jp.co.olympus.camerakit.OLYCameraPropertyListener;
@@ -266,15 +268,35 @@ public class OlyCameraStatusWrapper implements ICameraStatus, ICameraStatusWatch
             currentWBMode = wbMode;
             updateReceiver.updatedWBMode(currentWBMode);
         }
-        String remainBattery = getPropertyTitle(olyCamera, "BATTERY_LEVEL");
-        if (!remainBattery.equals(currentRemainBattery))
-        {
-            currentRemainBattery = remainBattery;
-            int percentage = 0;
-
-            Log.v(TAG, "currentRemainBattery : " + currentRemainBattery);
 
-            updateReceiver.updateRemainBattery(percentage);
+        try
+        {
+            String remainBattery = olyCamera.getCameraPropertyValue("BATTERY_LEVEL");
+            if (!remainBattery.equals(currentRemainBattery))
+            {
+               Map<String, Integer> batteryIconList = new HashMap<String, Integer>() {
+                    {
+                        put("<BATTERY_LEVEL/UNKNOWN>"       , 0);
+                        put("<BATTERY_LEVEL/CHARGE>"        , 100);
+                        put("<BATTERY_LEVEL/EMPTY>"         , 0);
+                        put("<BATTERY_LEVEL/WARNING>"       , 30);
+                        put("<BATTERY_LEVEL/LOW>"           , 50);
+                        put("<BATTERY_LEVEL/FULL>"          , 100);
+                        put("<BATTERY_LEVEL/EMPTY_AC>"       , 0);
+                        put("<BATTERY_LEVEL/SUPPLY_WARNING>", 30);
+                        put("<BATTERY_LEVEL/SUPPLY_LOW>"    , 50);
+                        put("<BATTERY_LEVEL/SUPPLY_FULL>"   , 100);
+                    }
+                };
+                currentRemainBattery = remainBattery;
+                int percentage = batteryIconList.get(remainBattery);
+                Log.v(TAG, "currentRemainBattery : " + currentRemainBattery + "(" + percentage + ")");
+                updateReceiver.updateRemainBattery(percentage);
+            }
+        }
+        catch (Exception ee)
+        {
+            ee.printStackTrace();
         }
         String shutterSpeed = getPropertyTitle(olyCamera, "SHUTTER");
         if (!shutterSpeed.equals(currentShutterSpeed))
index 4435b4e..a1bfca3 100644 (file)
@@ -123,6 +123,14 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
                     statusNotify.toggleShowGridFrame();
                     statusViewDrawer.updateGridIcon();
                     break;
+                case R.id.zoom_in_button:
+                    // ズームインのボタンが押された
+                    actionZoomin();
+                    break;
+                case R.id.zoom_out_button:
+                    // ズームアウトのボタンが押された
+                    actionZoomout();
+                    break;
 /*
                 case R.id.camera_property_settings_button:
                     // カメラのプロパティ設定
@@ -143,15 +151,6 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi
                     // お気に入り設定のダイアログを表示する
                     showFavoriteDialog();
                     break;
-
-                case R.id.btn_zoomin:
-                    // ズームインのボタンが押された
-                    actionZoomin();
-                    break;
-                case R.id.btn_zoomout:
-                    // ズームアウトのボタンが押された
-                    actionZoomout();
-                    break;
 */
                 default:
                     Log.v(TAG, "onClick() : " + id);
index bd71b9c..9069974 100644 (file)
@@ -34,6 +34,7 @@ import net.osdn.gokigen.gr2control.camera.IDisplayInjector;
 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.liveview.liveviewlistener.ILiveViewListener;
 import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
 import net.osdn.gokigen.gr2control.scene.IChangeScene;
@@ -49,7 +50,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
     private final String TAG = this.toString();
 
     private ILiveViewControl liveViewControl = null;
-    //private IZoomLensControl zoomLensControl = null;
+    private IZoomLensControl zoomLensControl = null;
     private IInterfaceProvider interfaceProvider = null;
     private IDisplayInjector interfaceInjector = null;
     //private OlympusCameraLiveViewListenerImpl liveViewListener = null;
@@ -168,6 +169,8 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             setOnClickListener(view, R.id.camera_power_off_button);
             setOnClickListener(view, R.id.show_preference_button);
             setOnClickListener(view, R.id.show_hide_grid_button);
+            setOnClickListener(view, R.id.zoom_in_button);
+            setOnClickListener(view, R.id.zoom_out_button);
 
             if (onPanelClickListener == null)
             {
@@ -289,7 +292,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
         this.interfaceProvider = interfaceProvider;
         this.interfaceInjector = interfaceProvider.getDisplayInjector();
         this.liveViewControl = interfaceProvider.getLiveViewControl();
-        //this.zoomLensControl = interfaceProvider.getZoomLensControl();
+        this.zoomLensControl = interfaceProvider.getZoomLensControl();
         this.cameraInformation = interfaceProvider.getCameraInformation();
         this.statusWatcher = interfaceProvider.getCameraStatusWatcher();
     }
@@ -594,6 +597,19 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             // ここでグリッドアイコンを更新する
             updateGridIcon();
 
+            // ここでズームレンズ制御ができるか確認する
+            if ((zoomLensControl != null)&&(zoomLensControl.canZoom()))
+            {
+                //Log.v(TAG, "CAN ZOOM LENS");
+                updateZoomlensControl(true);
+            }
+            else
+            {
+                //Log.v(TAG, "NO ZOOM LENS");
+                updateZoomlensControl(false);
+            }
+
+
             // ステータス監視も実施する
             startWatchStatus();
         }
@@ -629,6 +645,45 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
     /**
      *
      *
+     *
+     */
+    private void updateZoomlensControl(final boolean isVisible)
+    {
+        runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                // isVisibleがtrueなら、ズームレンズボタンを有効にする
+                Activity activity = getActivity();
+                if (activity != null)
+                {
+                    try
+                    {
+                        View view1 = activity.findViewById(R.id.zoom_out_button);
+                        if (view1 != null)
+                        {
+                            view1.setVisibility((isVisible) ? View.VISIBLE : View.INVISIBLE);
+                            view1.invalidate();
+                        }
+
+                        View view2 = activity.findViewById(R.id.zoom_in_button);
+                        if (view2 != null)
+                        {
+                            view2.setVisibility((isVisible) ? View.VISIBLE : View.INVISIBLE);
+                            view2.invalidate();
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        });
+    }
+
+    /**
+     *
+     *
      */
     private void startWatchStatus()
     {
@@ -874,6 +929,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
                 iconId = R.drawable.ic_battery_full_black_24dp;
             }
             final int id = iconId;
+            final boolean isAlert = (percentage < 20);
             activity.runOnUiThread(new Runnable()
             {
                 @Override
@@ -882,8 +938,16 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
                     ImageView view = activity.findViewById(R.id.currentBatteryImageView);
                     if (view != null)
                     {
-                        view.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
-                        view.invalidate();
+                        Drawable target = ResourcesCompat.getDrawable(getResources(), id, null);
+                        if (target != null)
+                        {
+                            if (isAlert)
+                            {
+                                DrawableCompat.setTint(target, Color.RED);
+                            }
+                            view.setImageDrawable(target);
+                            view.invalidate();
+                        }
                     }
                 }
             });
index 752e10d..54475ab 100644 (file)
@@ -137,6 +137,9 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Shar
         if (!items.containsKey(IPreferencePropertyAccessor.SHARE_AFTER_SAVE)) {
             editor.putBoolean(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, false);
         }
+        if (!items.containsKey(IPreferencePropertyAccessor.USE_PLAYBACK_MENU)) {
+            editor.putBoolean(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, false);
+        }
         editor.apply();
     }
 
@@ -346,6 +349,11 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Shar
                     Log.v(TAG, " " + key + " , " + value);
                     break;
 
+                case IPreferencePropertyAccessor.USE_PLAYBACK_MENU:
+                    value = preferences.getBoolean(key, false);
+                    Log.v(TAG, " " + key + " , " + value);
+                    break;
+
                 default:
                     String strValue = preferences.getString(key, "");
                     setListPreference(key, key, strValue);
index 370aa54..f011fc4 100644 (file)
                 android:src="@drawable/ic_grid_off_black_24dp"
                 android:visibility="visible" />
 
+            <ImageView
+                android:id="@+id/zoom_in_button"
+                android:layout_width="match_parent"
+                android:layout_height="24dp"
+                android:layout_alignParentStart="true"
+                android:layout_alignParentLeft="true"
+                android:layout_below="@id/show_images_button"
+                android:layout_marginTop="16dp"
+                android:clickable="true"
+                android:focusable="true"
+                android:gravity="center"
+                android:scaleType="fitCenter"
+                android:src="@drawable/ic_add_circle_outline_black_24dp"
+                android:visibility="invisible" />
+
+            <ImageView
+                android:id="@+id/zoom_out_button"
+                android:layout_width="match_parent"
+                android:layout_height="24dp"
+                android:layout_alignParentStart="true"
+                android:layout_alignParentLeft="true"
+                android:layout_above="@id/show_hide_grid_button"
+                android:layout_marginBottom="16dp"
+                android:clickable="true"
+                android:focusable="true"
+                android:gravity="center"
+                android:scaleType="fitCenter"
+                android:src="@drawable/ic_remove_circle_outline_black_24dp"
+                android:visibility="invisible" />
+
         </RelativeLayout>
 
         <view
index 537c12f..0d2bb8a 100644 (file)
             android:layout_height="0dip"
             android:layout_weight="1"
             android:background="@color/colorBlack">
+
+            <ImageView
+                android:id="@+id/area_spacer001"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:clickable="true"
+                android:focusable="true"
+                android:gravity="center"
+                android:scaleType="fitCenter"
+                android:visibility="invisible" />
+
+            <ImageView
+                android:id="@+id/zoom_out_button"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:scaleType="fitCenter"
+                android:visibility="invisible"
+                android:clickable="true"
+                android:focusable="true"
+                android:src="@drawable/ic_remove_circle_outline_black_24dp"
+                android:gravity="center" />
+
+            <ImageView
+                android:id="@+id/area_spacer002"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:clickable="true"
+                android:focusable="true"
+                android:gravity="center"
+                android:scaleType="fitCenter"
+                android:visibility="invisible" />
+
+            <ImageView
+                android:id="@+id/zoom_in_button"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:scaleType="fitCenter"
+                android:visibility="invisible"
+                android:clickable="true"
+                android:focusable="true"
+                android:src="@drawable/ic_add_circle_outline_black_24dp"
+                android:gravity="center" />
+
+            <ImageView
+                android:id="@+id/area_spacer003"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:clickable="true"
+                android:focusable="true"
+                android:gravity="center"
+                android:scaleType="fitCenter"
+                android:visibility="invisible" />
+
         </LinearLayout>
 
         <LinearLayout
index 376a0fd..8b1e319 100644 (file)
     <string name="camera_disconnected">切断</string>
     <string name="action_synchroize_datetime">時刻の同期</string>
     <string name="action_info">情報</string>
-    <string name="action_download">画像取得</string>
-    <string name="action_download_movie">動画取得</string>
-    <string name="action_download_original_movie">動画の取得(オリジナルサイズ)</string>
+    <string name="action_download">画像取得</string>
+    <string name="action_download_movie">動画取得</string>
+    <string name="action_download_original_movie">オリジナルサイズ</string>
     <string name="action_delete_movie">削除</string>
     <string name="action_get_information">画像情報</string>
     <string name="action_download_2048x1536">2048 x 1536</string>
     <string name="action_download_1920x1440">1920 x 1440</string>
     <string name="action_download_1600x1200">1600 x 1200</string>
     <string name="action_download_1024x768">1024 x 768</string>
-    <string name="action_download_original_size">画像の取得(オリジナルサイズ)</string>
-    <string name="action_download_640x480">画像の取得(小さいサイズ)</string>
-    <string name="action_download_raw">画像の取得(RAWファイル)</string>
+    <string name="action_download_original_size">オリジナルサイズ</string>
+    <string name="action_download_640x480">小さいサイズ</string>
+    <string name="action_download_raw">RAW</string>
     <string name="action_delete_picture">削除</string>
     <string name="dialog_get_information_title">画像の情報</string>
     <string name="label_aelock">AEL/AFL</string>