implementation 'com.android.support:preference-v7:28.0.0-rc01'
implementation 'com.android.support:exifinterface:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
+
+ api files('libs/olycamerakit.jar')
}
super.onPause();
try
{
- ICameraConnection connection = getCameraConnection(interfaceProvider.getCammeraConnectionMethod());
+ ICameraConnection connection = interfaceProvider.getCameraConnection();
if (connection != null)
{
connection.stopWatchWifiStatus(this);
e.printStackTrace();
}
}
-
- /**
- *
- *
- *
- */
- private ICameraConnection getCameraConnection(ICameraConnection.CameraConnectionMethod connectionMethod)
- {
- Log.v(TAG, "getCameraConnection() : " + connectionMethod);
- return (interfaceProvider.getRicohGr2Infterface().getRicohGr2CameraConnection());
-/*
- ICameraConnection connection;
- if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
- {
- connection = interfaceProvider.getRicohGr2Infterface().getRicohGr2CameraConnection();
- }
- else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
- {
- connection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
- }
- else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
- {
- connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
- }
- return (connection);
-*/
- }
}
package net.osdn.gokigen.gr2control.camera;
import android.app.Activity;
+import android.content.SharedPreferences;
import android.support.annotation.NonNull;
-import net.osdn.gokigen.gr2control.camera.ricohgr2.IRicohGr2InterfaceProvider;
+import android.support.v7.preference.PreferenceManager;
+
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.OlympusInterfaceProvider;
+import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
import net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper.RicohGr2InterfaceProvider;
+import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
+import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
/**
*
public class CameraInterfaceProvider implements IInterfaceProvider
{
//private final Activity context;
- //private final OlympusInterfaceProvider olympus;
//private final SonyCameraWrapper sony;
+ private final OlympusInterfaceProvider olympus;
private final RicohGr2InterfaceProvider ricohGr2;
+ private final Activity context;
+ private ICameraConnection.CameraConnectionMethod connectionMethod = ICameraConnection.CameraConnectionMethod.UNKNOWN;
public static IInterfaceProvider newInstance(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
{
*/
private CameraInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
{
- //this.context = context;
- //olympus = new OlympusInterfaceProvider(context, provider);
- //sony = new SonyCameraWrapper(context, provider);
+ this.context = context;
+ olympus = new OlympusInterfaceProvider(context, provider);
ricohGr2 = new RicohGr2InterfaceProvider(context, provider);
+ //sony = new SonyCameraWrapper(context, provider);
}
/*
}
*/
+/*
+ @Override
+ public IRicohGr2InterfaceProvider getRicohGr2Infterface()
+ {
+ return (ricohGr2);
+ }
+*/
+
/**
*
*
*/
@Override
- public IRicohGr2InterfaceProvider getRicohGr2Infterface()
+ public ICameraConnection getCameraConnection()
{
- return (ricohGr2);
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getOlyCameraConnection());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getRicohGr2CameraConnection());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public ICameraButtonControl getButtonControl()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getButtonControl());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getButtonControl());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public IDisplayInjector getDisplayInjector()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getDisplayInjector());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getDisplayInjector());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public ILiveViewControl getLiveViewControl()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getLiveViewControl());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getLiveViewControl());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public ILiveViewListener getLiveViewListener()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getLiveViewListener());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getLiveViewListener());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public IFocusingControl getFocusingControl()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getFocusingControl());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getFocusingControl());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public ICameraInformation getCameraInformation()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getCameraInformation());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getCameraInformation());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public IZoomLensControl getZoomLensControl()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getZoomLensControl());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getZoomLensControl());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public ICaptureControl getCaptureControl()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getCaptureControl());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getCaptureControl());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public ICameraStatus getCameraStatusListHolder()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getCameraStatusListHolder());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getCameraStatusListHolder());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public ICameraStatusWatcher getCameraStatusWatcher()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getCameraStatusWatcher());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getCameraStatusWatcher());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public IPlaybackControl getPlaybackControl()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getPlaybackControl());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getPlaybackControl());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public ICameraHardwareStatus getHardwareStatus()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getHardwareStatus());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getHardwareStatus());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public ICameraRunMode getCameraRunMode()
+ {
+ try
+ {
+ ICameraConnection.CameraConnectionMethod connectionMethod = getCammeraConnectionMethodImpl();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ return (olympus.getCameraRunMode());
+ }
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
+ {
+ return (ricohGr2.getCameraRunMode());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
}
/**
- * OPCカメラを使用するかどうか ... 今回はGR2専用
+ * OPC/GR2/SONY カメラを使用するかどうか
*
* @return OPC / SONY / RICOH_GR2 (ICameraConnection.CameraConnectionMethod)
*/
public ICameraConnection.CameraConnectionMethod getCammeraConnectionMethod()
{
- return (ICameraConnection.CameraConnectionMethod.RICOH_GR2);
-/*
- ICameraConnection.CameraConnectionMethod ret = ICameraConnection.CameraConnectionMethod.OPC;
+ return (getCammeraConnectionMethodImpl());
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void resetCameraConnectionMethod()
+ {
+ connectionMethod = ICameraConnection.CameraConnectionMethod.UNKNOWN;
+ }
+
+ /**
+ *
+ *
+ */
+ private ICameraConnection.CameraConnectionMethod getCammeraConnectionMethodImpl()
+ {
+ if (connectionMethod != ICameraConnection.CameraConnectionMethod.UNKNOWN)
+ {
+ return (connectionMethod);
+ }
+ ICameraConnection.CameraConnectionMethod ret;
try
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- String connectionMethod = preferences.getString(IPreferencePropertyAccessor.CONNECTION_METHOD, "OPC");
- if (connectionMethod.contains("SONY"))
+ String connectionMethod = preferences.getString(IPreferencePropertyAccessor.CONNECTION_METHOD, "RICOH_GR2");
+ if (connectionMethod.contains("RICOH_GR2"))
{
- ret = ICameraConnection.CameraConnectionMethod.SONY;
+ ret = ICameraConnection.CameraConnectionMethod.RICOH_GR2;
}
- else if (connectionMethod.contains("RICOH_GR2"))
+ else // if (connectionMethod.contains("OPC"))
{
- ret = ICameraConnection.CameraConnectionMethod.RICOH_GR2;
+ ret = ICameraConnection.CameraConnectionMethod.OPC;
}
+/*
+ else if (connectionMethod.contains("SONY"))
+ {
+ ret = ICameraConnection.CameraConnectionMethod.SONY;
+ }
+*/
}
catch (Exception e)
{
e.printStackTrace();
+ ret = ICameraConnection.CameraConnectionMethod.UNKNOWN;
}
- return (ret);
-*/
+ connectionMethod = ret;
+ return (connectionMethod);
}
}
{
enum CameraConnectionMethod
{
+ UNKNOWN,
OPC,
SONY,
- RICOH_GR2
+ RICOH_GR2,
}
enum CameraConnectionStatus
--- /dev/null
+package net.osdn.gokigen.gr2control.camera;
+
+import java.util.Map;
+
+/**
+ *
+ *
+ */
+public interface ICameraHardwareStatus
+{
+ boolean isAvailableHardwareStatus();
+ String getLensMountStatus();
+ String getMediaMountStatus();
+
+ float getMinimumFocalLength();
+ float getMaximumFocalLength();
+ float getActualFocalLength();
+
+ Map<String, Object> inquireHardwareInformation();
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera;
+
+public interface ICameraRunMode
+{
+ /** カメラの動作モード変更 **/
+ void changeRunMode(boolean isRecording);
+ boolean isRecordingMode();
+}
package net.osdn.gokigen.gr2control.camera;
-import net.osdn.gokigen.gr2control.camera.ricohgr2.IRicohGr2InterfaceProvider;
+import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
+import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
/**
*
*/
public interface IInterfaceProvider
{
- //IOlympusInterfaceProvider getOlympusInterface();
- //IOlympusLiveViewListener getOlympusLiveViewListener();
- //ISonyInterfaceProvider getSonyInterface();
- IRicohGr2InterfaceProvider getRicohGr2Infterface();
+
+ ICameraConnection getCameraConnection();
+ ICameraButtonControl getButtonControl();
+
+ IDisplayInjector getDisplayInjector();
+
+ ILiveViewControl getLiveViewControl();
+ ILiveViewListener getLiveViewListener();
+ IFocusingControl getFocusingControl();
+ ICameraInformation getCameraInformation();
+ IZoomLensControl getZoomLensControl();
+ ICaptureControl getCaptureControl();
+ ICameraStatus getCameraStatusListHolder();
+ ICameraStatusWatcher getCameraStatusWatcher();
+
+ IPlaybackControl getPlaybackControl();
+
+ ICameraHardwareStatus getHardwareStatus();
+ ICameraRunMode getCameraRunMode();
ICameraConnection.CameraConnectionMethod getCammeraConnectionMethod();
+ void resetCameraConnectionMethod();
}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus;
+
+import net.osdn.gokigen.gr2control.camera.ICameraButtonControl;
+import net.osdn.gokigen.gr2control.camera.ICameraConnection;
+import net.osdn.gokigen.gr2control.camera.ICameraHardwareStatus;
+import net.osdn.gokigen.gr2control.camera.ICameraInformation;
+import net.osdn.gokigen.gr2control.camera.ICameraStatus;
+import net.osdn.gokigen.gr2control.camera.ICameraStatusWatcher;
+import net.osdn.gokigen.gr2control.camera.ICaptureControl;
+import net.osdn.gokigen.gr2control.camera.IDisplayInjector;
+import net.osdn.gokigen.gr2control.camera.IFocusingControl;
+import net.osdn.gokigen.gr2control.camera.ILiveViewControl;
+import net.osdn.gokigen.gr2control.camera.IZoomLensControl;
+import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
+import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
+import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
+
+/**
+ *
+ */
+public interface IOlympusInterfaceProvider
+{
+ ICameraConnection getOlyCameraConnection();
+ ILiveViewControl getLiveViewControl();
+ ILiveViewListener getLiveViewListener();
+ IFocusingControl getFocusingControl();
+ ICameraInformation getCameraInformation();
+ IZoomLensControl getZoomLensControl();
+ ICaptureControl getCaptureControl();
+ ICameraButtonControl getButtonControl();
+ IDisplayInjector getDisplayInjector();
+
+ IOlyCameraPropertyProvider getCameraPropertyProvider();
+
+ ICameraStatus getCameraStatusListHolder();
+ ICameraStatusWatcher getCameraStatusWatcher();
+ IPlaybackControl getPlaybackControl();
+
+ ICameraHardwareStatus getHardwareStatus();
+ ICameraRunMode getCameraRunMode();
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.cameraproperty;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.util.List;
+
+public class CameraPropertyArrayAdapter extends ArrayAdapter<CameraPropertyArrayItem>
+{
+ private LayoutInflater inflater;
+ private final int textViewResourceId;
+ private List<CameraPropertyArrayItem> listItems;
+
+ CameraPropertyArrayAdapter(Context context, int textId, List<CameraPropertyArrayItem> items)
+ {
+ super(context, textId, items);
+
+ textViewResourceId = textId;
+ listItems = items;
+
+ inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public @NonNull View getView(int position, View convertView, @NonNull ViewGroup parent)
+ {
+ View view;
+ if(convertView != null)
+ {
+ view = convertView;
+ }
+ else
+ {
+ view = inflater.inflate(textViewResourceId, null);
+ }
+
+ CameraPropertyArrayItem item = listItems.get(position);
+
+ ImageView imageView = view.findViewWithTag("icon");
+ imageView.setImageResource(item.getIconResource());
+
+ TextView titleView = view.findViewWithTag("name");
+ titleView.setText(item.getPropertyName());
+
+ TextView detailView = view.findViewWithTag("title");
+ detailView.setText(item.getPropertyTitle());
+
+ TextView optionView = view.findViewWithTag("value");
+ optionView.setText(item.getPropertyValueTitle());
+
+ return (view);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.cameraproperty;
+
+
+public class CameraPropertyArrayItem
+{
+ private int iconResource;
+ private final String propertyName;
+ private final String propertyTitle;
+ private final String initialValue;
+ private final String initialValueTitle;
+ private final int initialIconResource;
+ private String propertyValue;
+ private String propertyValueTitle;
+
+ CameraPropertyArrayItem(String name, String title, String valueTitle, String value, int iconId1)
+ {
+ iconResource = iconId1;
+ propertyName = name;
+ propertyTitle = title;
+ propertyValueTitle = valueTitle;
+ propertyValue = value;
+ initialValueTitle = valueTitle;
+ initialValue = value;
+ initialIconResource = iconId1;
+ }
+
+ public boolean isChanged()
+ {
+ return (!propertyValue.equals(initialValue));
+ }
+
+ public String getPropertyName()
+ {
+ return (propertyName);
+ }
+
+ public String getPropertyTitle()
+ {
+ return (propertyTitle);
+ }
+
+ public String getInitialValue()
+ {
+ return (initialValue);
+ }
+
+ public int getIconResource()
+ {
+ return (iconResource);
+ }
+
+ public void setIconResource(int iconId)
+ {
+ iconResource = iconId;
+ }
+
+ public String getPropertyValueTitle()
+ {
+ return (propertyValueTitle);
+ }
+
+ public String getPropertyValue()
+ {
+ return (propertyValue);
+ }
+
+ public void setPropertyValue(String valueTitle, String value)
+ {
+ propertyValueTitle = valueTitle;
+ propertyValue = value;
+ }
+
+ public void resetValue()
+ {
+ propertyValue = initialValue;
+ propertyValueTitle = initialValueTitle;
+ iconResource = initialIconResource;
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.cameraproperty;
+
+
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.R;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Set;
+
+public class CameraPropertyLoader implements Runnable
+{
+ private final String TAG = toString();
+ private final IOlyCameraPropertyProvider propertyInterface;
+ private final IPropertyLoaderCallback callback;
+ private ArrayList<CameraPropertyArrayItem> propertyItems = null;
+
+ CameraPropertyLoader(IOlyCameraPropertyProvider propertyInterface, IPropertyLoaderCallback callback)
+ {
+ this.propertyInterface = propertyInterface;
+ this.callback = callback;
+ }
+
+ @Override
+ public void run()
+ {
+ Log.v(TAG, "CameraPropertyLoader::run() START");
+
+ propertyItems = new ArrayList<>();
+
+ // カメラプロパティを設定する
+ Set<String> names = propertyInterface.getCameraPropertyNames();
+ for (String name : names)
+ {
+ String title = propertyInterface.getCameraPropertyTitle(name);
+ String value = propertyInterface.getCameraPropertyValue(name);
+ String rawValue = propertyInterface.getCameraPropertyValueTitle(value);
+ int iconId = (propertyInterface.canSetCameraProperty(name)) ? R.drawable.ic_web_asset_black_24dp : R.drawable.ic_block_black_24dp;
+
+ propertyItems.add(new CameraPropertyArrayItem(name, title, rawValue, value, iconId));
+ }
+
+ // プロパティ名でソートしてしまおう。。。
+ Collections.sort(propertyItems, new Comparator<CameraPropertyArrayItem>() {
+ public int compare(CameraPropertyArrayItem o1, CameraPropertyArrayItem o2) {
+ return o1.getPropertyName().compareTo(o2.getPropertyName());
+ }
+ });
+
+
+
+ // 終了通知
+ callback.finished();
+
+ Log.v(TAG, "CameraPropertyLoader::run() END");
+ }
+
+ public void resetProperty()
+ {
+ Log.v(TAG, "CameraPropertyLoader::resetProperty() START");
+
+ for (CameraPropertyArrayItem item : propertyItems)
+ {
+ item.resetValue();
+ }
+ callback.resetProperty();
+ Log.v(TAG, "CameraPropertyLoader::resetProperty() END");
+
+ }
+
+ /**
+ * プロパティ一覧を応答
+ *
+ */
+ public ArrayList<CameraPropertyArrayItem> getItemList()
+ {
+ return (propertyItems);
+ }
+
+ public interface IPropertyLoaderCallback
+ {
+ void finished();
+ void resetProperty();
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.cameraproperty;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.View;
+
+import net.osdn.gokigen.gr2control.R;
+import net.osdn.gokigen.gr2control.scene.ConfirmationDialog;
+
+
+public class CameraPropertyOperator implements View.OnClickListener
+{
+ private final String TAG = toString();
+
+ private final Context context;
+ private final CameraPropertyLoader loader;
+
+
+ CameraPropertyOperator(Context context, CameraPropertyLoader loader)
+ {
+ this.context = context;
+ this.loader = loader;
+ }
+
+ @Override
+ public void onClick(View view)
+ {
+ int id = view.getId();
+ Log.v(TAG, "onClick() : " + id);
+ switch (id)
+ {
+ case R.id.propertySettings_restore:
+ processRestoreCameraProperty();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ private void processRestoreCameraProperty()
+ {
+ try
+ {
+ final ConfirmationDialog dialog = ConfirmationDialog.newInstance(context);
+ dialog.show(R.string.dialog_title_confirmation,
+ R.string.dialog_message_restore_camera_property,
+ new ConfirmationDialog.Callback() {
+ @Override
+ public void confirm()
+ {
+ loader.resetProperty();
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.cameraproperty;
+
+import android.content.Context;
+import android.content.DialogInterface;
+import android.support.v7.app.AlertDialog;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
+
+import net.osdn.gokigen.gr2control.R;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
+
+import java.util.List;
+
+public class CameraPropertyValueSelector implements ListView.OnItemClickListener, ListView.OnLongClickListener, DialogInterface.OnClickListener
+{
+ private final String TAG = toString();
+ private final Context context;
+ private final IOlyCameraPropertyProvider propertyInterface;
+ private final ICametaPropertyUpdateNotify updater;
+
+ private List<String> valueList = null;
+ private CameraPropertyArrayItem item = null;
+
+ /**
+ * 選択されたアイテムの更新を行う
+ *
+ *
+ */
+ CameraPropertyValueSelector(Context context, IOlyCameraPropertyProvider propertyInterface, ICametaPropertyUpdateNotify updater)
+ {
+ this.context = context;
+ this.propertyInterface = propertyInterface;
+ this.updater = updater;
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l)
+ {
+ Log.v(TAG, "onItemClick() : " + i);
+ CameraPropertyArrayAdapter arrayAdapter = (CameraPropertyArrayAdapter) adapterView.getAdapter();
+ item = arrayAdapter.getItem(i);
+ //item = (CameraPropertyArrayItem) listView.getSelectedItem();
+ if ((item == null)||(propertyInterface == null))
+ {
+ Log.i(TAG, "----- selectedItem is NULL. -----");
+ return;
+ }
+
+ String propertyName = item.getPropertyName();
+ String propertyValue = propertyInterface.getCameraPropertyValue(propertyName);
+ Log.v(TAG, "TARGET PROPERTY : " + propertyName + " " + propertyValue);
+
+ valueList = propertyInterface.getCameraPropertyValueList(propertyName);
+ if ((valueList == null)||(valueList.size() == 0))
+ {
+ Log.v(TAG, "Value List is NULL : " + item.getPropertyName() + " " + propertyValue);
+ return;
+ }
+ String[] items;
+ if (item.getIconResource() == R.drawable.ic_block_black_24dp)
+ {
+ // Read only, 値の変更はできない
+ items = new String[1];
+ items[0] = propertyInterface.getCameraPropertyValueTitle(propertyValue);
+ }
+ else
+ {
+ // 設定可能な選択肢を一覧表示する
+ items = new String[valueList.size()];
+ for (int index = 0; index < valueList.size(); index++)
+ {
+ String propValue = valueList.get(index);
+ if (propValue.equals(item.getInitialValue()))
+ {
+ Log.v(TAG, "INIT: " + propValue);
+
+ // 初期値には、(*) マークを表示したい
+ items[index] = propertyInterface.getCameraPropertyValueTitle(propValue) + " (*)";
+ }
+ else
+ {
+ items[index] = propertyInterface.getCameraPropertyValueTitle(propValue);
+ }
+ }
+ }
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setSingleChoiceItems(items, valueList.indexOf(item.getPropertyValue()), this);
+ builder.setCancelable(true);
+ builder.show();
+ }
+
+ @Override
+ public boolean onLongClick(View view)
+ {
+ return (false);
+ }
+
+ @Override
+ public void onClick(DialogInterface dialogInterface, int which)
+ {
+ dialogInterface.dismiss();
+ if (propertyInterface == null)
+ {
+ Log.i(TAG, "----- PROPERTY CHANGE INTERFACE IS NULL -----");
+ return;
+ }
+
+ String propertyValue = valueList.get(which);
+ String rawValue = propertyInterface.getCameraPropertyValueTitle(propertyValue);
+
+ // パラメータ設定 (アイテムを個別に設定する場合は有効に...)
+ //propertyInterface.setCameraPropertyValue(propertyName, propertyValue);
+
+ if (item.getIconResource() == R.drawable.ic_block_black_24dp)
+ {
+ // Read Only パラメータは設定しない。
+ return;
+ }
+
+ item.setPropertyValue(rawValue, propertyValue);
+ String initialValue = item.getInitialValue();
+ if (!initialValue.equals(propertyValue))
+ {
+ // 値を変更したマークにする
+ item.setIconResource(R.drawable.ic_mode_edit_black_24dp);
+ }
+ else
+ {
+ // デフォルト値なので、アイコンを初期アイコンに戻す
+ item.setIconResource(R.drawable.ic_web_asset_black_24dp);
+ }
+ if (updater != null)
+ {
+ updater.onCameraPropertyUpdate(which);
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.cameraproperty;
+
+
+public interface ICametaPropertyUpdateNotify
+{
+ void onCameraPropertyUpdate(int which);
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.cameraproperty;
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.Fragment;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+
+import net.osdn.gokigen.gr2control.R;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
+
+import java.util.HashMap;
+
+public class OlyCameraPropertyListFragment extends Fragment implements CameraPropertyLoader.IPropertyLoaderCallback
+{
+ private final String TAG = toString();
+ private IOlyCameraPropertyProvider propertyInterface = null;
+
+ private CameraPropertyLoader propertyLoader = null;
+ private CameraPropertyOperator propertyOperator = null;
+ private ProgressDialog busyDialog = null;
+ private ListView listView = null;
+
+ /**
+ * カメラプロパティをやり取りするインタフェースを生成する
+ *
+ */
+ public static OlyCameraPropertyListFragment newInstance(@NonNull Context context, @NonNull IOlyCameraPropertyProvider propertyInterface)
+ {
+ OlyCameraPropertyListFragment instance = new OlyCameraPropertyListFragment();
+ instance.prepare(context, propertyInterface);
+
+ // パラメータはBundleにまとめておく
+ Bundle arguments = new Bundle();
+ //arguments.putString("title", title);
+ //arguments.putString("message", message);
+ instance.setArguments(arguments);
+
+ return (instance);
+ }
+
+ private void prepare(@NonNull Context context, @NonNull IOlyCameraPropertyProvider propertyInterface)
+ {
+ Log.v(TAG, "prepare()");
+
+ this.propertyInterface = propertyInterface;
+ if (propertyLoader == null)
+ {
+ propertyLoader = new CameraPropertyLoader(propertyInterface, this);
+ }
+ if (propertyOperator == null)
+ {
+ propertyOperator = new CameraPropertyOperator(context, propertyLoader);
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ Log.v(TAG, "onCreate()");
+
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onAttach(Context context)
+ {
+ super.onAttach(context);
+ Log.v(TAG, "onAttach()");
+ }
+ /**
+ *
+ *
+ */
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+ Log.v(TAG, "onCreateView()");
+
+ View view = inflater.inflate(R.layout.fragmant_camera_property, container, false);
+ setHasOptionsMenu(true);
+
+ listView = view.findViewById(R.id.CameraPropertyListView);
+
+ ImageView restore_properties = view.findViewById(R.id.propertySettings_restore);
+ restore_properties.setOnClickListener(propertyOperator);
+
+ return (view);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
+ {
+ AppCompatActivity activity = (AppCompatActivity)getActivity();
+ if (activity != null)
+ {
+ ActionBar bar = activity.getSupportActionBar();
+ if (bar != null) {
+ bar.setTitle(getString(R.string.app_name));
+ }
+ }
+ }
+
+ /**
+ *
+ *
+ *
+ */
+ @Override
+ public void onStart()
+ {
+ super.onStart();
+ Log.v(TAG, "onStart()");
+
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onResume()
+ {
+ super.onResume();
+ Log.v(TAG, "onResume() Start");
+
+ loadCameraPropertyItems(true);
+
+ Log.v(TAG, "onResume() End");
+ }
+ /**
+ *
+ *
+ */
+ @Override
+ public void onPause()
+ {
+ super.onPause();
+ Log.v(TAG, "onPause() Start");
+
+ try
+ {
+ commitCameraPropertyItems();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ Log.v(TAG, "onPause() End");
+ }
+
+ private void runOnUiThread(Runnable action)
+ {
+ Activity activity = getActivity();
+ if (activity == null)
+ {
+ return;
+ }
+ activity.runOnUiThread(action);
+ }
+
+ private void loadCameraPropertyItems(boolean isPropertyLoad)
+ {
+ // 実行中ダイアログを取得する
+ busyDialog = new ProgressDialog(getActivity());
+ busyDialog.setTitle(getString(R.string.dialog_title_loading_properties));
+ busyDialog.setMessage(getString(R.string.dialog_message_loading_properties));
+ busyDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ busyDialog.setCancelable(false);
+ busyDialog.show();
+
+ // データ読み込み処理(別スレッドで実行)
+ if (isPropertyLoad)
+ {
+ new Thread(propertyLoader).start();
+ }
+ }
+
+ private void commitCameraPropertyItems()
+ {
+ ListAdapter adapter = listView.getAdapter();
+ int count = adapter.getCount();
+ Log.v(TAG, "----- CHANGED CAMERA PROPERTIES { -----");
+ final HashMap<String, String> propertiesToChange = new HashMap<>();
+ for (int index = 0; index < count; index++)
+ {
+ CameraPropertyArrayItem item = (CameraPropertyArrayItem) adapter.getItem(index);
+ if (item.isChanged())
+ {
+ Log.v(TAG, ">> " + item.getPropertyName() + " " + item.getPropertyValue());
+ propertiesToChange.put(item.getPropertyName(), item.getPropertyValue());
+ }
+ }
+ Log.v(TAG, "----- } CHANGED CAMERA PROPERTIES -----");
+ if (!propertiesToChange.isEmpty())
+ {
+ if (propertyInterface != null)
+ {
+ propertyInterface.setCameraPropertyValues(propertiesToChange);
+ }
+ else
+ {
+ Log.i(TAG, "----- PROPERTY CHANGE INTERFACE IS NULL -----");
+ }
+ }
+ }
+
+ @Override
+ public void finished()
+ {
+ runOnUiThread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ // アイテムをListに反映
+ if (listView != null)
+ {
+ final CameraPropertyArrayAdapter adapter = new CameraPropertyArrayAdapter(getContext(), R.layout.listarrayitems, propertyLoader.getItemList());
+ CameraPropertyValueSelector selector = new CameraPropertyValueSelector(getContext(), propertyInterface, new ICametaPropertyUpdateNotify() {
+ @Override
+ public void onCameraPropertyUpdate(int which)
+ {
+ Log.v(TAG, "onCameraPropertyUpdate()");
+ adapter.notifyDataSetChanged();
+ }
+ });
+ listView.setAdapter(adapter);
+ listView.setOnItemClickListener(selector);
+ listView.setOnLongClickListener(selector);
+ }
+
+ if (busyDialog != null)
+ {
+ busyDialog.dismiss();
+ busyDialog = null;
+ }
+ System.gc();
+ }
+ });
+ }
+
+ @Override
+ public void resetProperty()
+ {
+ try
+ {
+ Log.v(TAG, "resetProperty()");
+ CameraPropertyArrayAdapter adapter = (CameraPropertyArrayAdapter)listView.getAdapter();
+ adapter.notifyDataSetChanged();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops;
+
+interface ILoadSaveCameraProperties
+{
+ int MAX_STORE_PROPERTIES = 256; // お気に入り設定の最大記憶数...
+ String TITLE_KEY = "CameraPropTitleKey";
+ String DATE_KEY = "CameraPropDateTime";
+
+ void loadCameraSettings(final String id, final String dataName);
+ void saveCameraSettings(final String id, final String dataName);
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops;
+
+interface ILoadSaveMyCameraPropertyDialogDismiss
+{
+ void doDismissWithPropertyLoad(String id, String name);
+ void doDismissWithPropertySave(String id, String name);
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops;
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.v4.app.ListFragment;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ListView;
+
+import net.osdn.gokigen.gr2control.R;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+public class LoadMyCameraPropertyFragment extends ListFragment implements ListView.OnItemClickListener
+{
+ private final String TAG = toString();
+ private ILoadSaveMyCameraPropertyDialogDismiss dialogDismiss = null;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+ return (inflater.inflate(R.layout.list_camera_properties, container, false));
+ }
+
+ public void setDismissInterface(ILoadSaveMyCameraPropertyDialogDismiss dismiss)
+ {
+ this.dialogDismiss = dismiss;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+
+ List<MyCameraPropertySetItems> listItems = new ArrayList<>();
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+ for (int index = 1; index <= LoadSaveCameraProperties.MAX_STORE_PROPERTIES; index++)
+ {
+ String idHeader = String.format(Locale.ENGLISH, "%03d", index);
+ String prefDate = preferences.getString(idHeader + LoadSaveCameraProperties.DATE_KEY, "");
+ if (prefDate.length() <= 0)
+ {
+ //listItems.add(new MyCameraPropertySetItems(0, idHeader, "", ""));
+ break;
+ }
+ String prefTitle = preferences.getString(idHeader + LoadSaveCameraProperties.TITLE_KEY, "");
+ listItems.add(new MyCameraPropertySetItems(0, idHeader, prefTitle, prefDate));
+ }
+
+ //String prefDate = preferences.getString(LoadSaveCameraProperties.DATE_KEY, "");
+ //listItems.add(new MyCameraPropertySetItems(0, "000", getString(R.string.auto_save_props), prefDate));
+
+ MyCameraPropertyLoadArrayAdapter adapter = new MyCameraPropertyLoadArrayAdapter(getActivity(), R.layout.column_load, listItems);
+ setListAdapter(adapter);
+
+ getListView().setOnItemClickListener(this);
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View view, int position, long l)
+ {
+ final MyCameraPropertySetItems item = (MyCameraPropertySetItems) getListAdapter().getItem(position);
+ Log.v(TAG, "onItemClick() : " + position + " [" + item.getItemId() + "] " + item.getItemName() + " (" + item.getItemInfo() + ") " + item.getIconResource() + " ");
+
+ // アイテムを選択して終わらせる
+ if (dialogDismiss != null)
+ {
+ dialogDismiss.doDismissWithPropertyLoad(item.getItemId(), item.getItemName());
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops;
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.widget.Toast;
+
+import net.osdn.gokigen.gr2control.R;
+import net.osdn.gokigen.gr2control.camera.ICameraConnection;
+import net.osdn.gokigen.gr2control.camera.olympus.IOlympusInterfaceProvider;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.property.IOlyCameraProperty;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
+
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * カメラプロパティを一括でバックアップしたり、リストアしたりするクラス
+ *
+ */
+public class LoadSaveCameraProperties implements ILoadSaveCameraProperties
+{
+ private final String TAG = toString();
+
+ private final Activity parent;
+ private final ICameraConnection cameraConnection;
+ private final IOlyCameraPropertyProvider propertyProvider;
+
+ public LoadSaveCameraProperties(Activity context, IOlympusInterfaceProvider interfaceProvider)
+ {
+ this.parent = context;
+ this.cameraConnection = interfaceProvider.getOlyCameraConnection();
+ this.propertyProvider = interfaceProvider.getCameraPropertyProvider();
+ }
+
+ /**
+ * カメラの現在の設定を本体から読みだして記憶する
+ *
+ */
+ @Override
+ public void saveCameraSettings(final String idHeader, final String dataName)
+ {
+ Log.v(TAG, "saveCameraSettings() : START [" + idHeader + "], dataName: " + dataName);
+
+ // カメラから設定を一括で読みだして、Preferenceに記録する
+ if (cameraConnection.getConnectionStatus() == ICameraConnection.CameraConnectionStatus.CONNECTED)
+ {
+ //
+ // BUSYダイアログを表示する
+ //
+ final ProgressDialog busyDialog = new ProgressDialog(parent);
+ busyDialog.setMessage(parent.getString(R.string.dialog_start_save_property_message));
+ busyDialog.setTitle(parent.getString(R.string.dialog_start_save_property_title));
+ busyDialog.setIndeterminate(false);
+ busyDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ busyDialog.show();
+
+ try
+ {
+ Thread thread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ final boolean toast = saveCameraSettingsImpl(idHeader, dataName);
+ busyDialog.dismiss();
+
+ parent.runOnUiThread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ // Toast で保存したよのメッセージを表示
+ if (toast)
+ {
+ String storedMessage = parent.getString(R.string.saved_my_props) + dataName;
+ Toast.makeText(parent, storedMessage, Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+
+ }
+ });
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ Log.v(TAG, "PROPERTY STORED : " + idHeader + " " + dataName);
+ }
+ }
+
+ /**
+ * Preferenceにあるカメラの設定をカメラに登録する
+ * (注: Read Onlyなパラメータを登録しようとするとエラーになるので注意)
+ */
+ @Override
+ public void loadCameraSettings(final String idHeader, final String dataName)
+ {
+ Log.v(TAG, "loadCameraSettings() : START [" + idHeader + "], dataName: " + dataName);
+ if (cameraConnection.getConnectionStatus() == ICameraConnection.CameraConnectionStatus.CONNECTED)
+ {
+ //Log.v(TAG, "PROPERTY RESTORE ENTER : (" + id + ") " + name);
+
+ //
+ // BUSYダイアログを表示する
+ //
+ final ProgressDialog busyDialog = new ProgressDialog(parent);
+ busyDialog.setMessage(parent.getString(R.string.dialog_start_load_property_message));
+ busyDialog.setTitle(parent.getString(R.string.dialog_start_load_property_title));
+ busyDialog.setIndeterminate(false);
+ busyDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ busyDialog.show();
+
+ try
+ {
+ Thread thread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ //final boolean toast = loadCameraSettingsSequential(idHeader);
+ final boolean toast = loadCameraSettingsOnlyDifferences(idHeader);
+ busyDialog.dismiss();
+
+ parent.runOnUiThread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ // Toast で展開したよのメッセージを表示
+ if (toast)
+ {
+ String restoredMessage = parent.getString(R.string.restored_my_props) + dataName;
+ Toast.makeText(parent, restoredMessage, Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+ }
+ });
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ //Log.v(TAG, "PROPERTY RESTORE EXIT : (" + id + ") " + name);
+ }
+ }
+
+ /**
+ * カメラのプロパティを1つづつ個別設定
+ *
+ */
+ private boolean saveCameraSettingsImpl(String idHeader, String dataName)
+ {
+ boolean ret = false;
+ Map<String, String> values;
+ try
+ {
+ values = propertyProvider.getCameraPropertyValues(propertyProvider.getCameraPropertyNames());
+ if (values != null)
+ {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ SharedPreferences.Editor editor = preferences.edit();
+ for (String key : values.keySet())
+ {
+ editor.putString(idHeader + key, values.get(key));
+ //Log.v(TAG, "storeCameraSettings(): " + idHeader + key + " , " + values.get(key));
+ }
+ DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
+ editor.putString(idHeader + DATE_KEY, dateFormat.format(new Date()));
+ editor.putString(idHeader + TITLE_KEY, dataName);
+ //editor.commit();
+ editor.apply();
+
+ ret = true;
+ Log.v(TAG, "storeCameraSettings() COMMITED : " + idHeader + " [" + dataName + "]");
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ ret = false;
+ }
+ return (ret);
+ //Log.v(TAG, "CameraPropertyBackupRestore::storeCameraSettings() : " + idHeader);
+ }
+
+ /**
+ * カメラのプロパティを1つづつ個別設定
+ *
+ */
+ private boolean loadCameraSettingsSequential(String idHeader)
+ {
+ boolean ret = false;
+ int setCount = 0;
+ // Restores my settings.
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ if (cameraConnection.getConnectionStatus() == ICameraConnection.CameraConnectionStatus.CONNECTED)
+ {
+ String takeModeValue = preferences.getString(idHeader + IOlyCameraProperty.TAKE_MODE, null);
+ try
+ {
+ // TAKEMODE だけは先行して設定する(設定できないカメラプロパティもあるので...)
+ if (takeModeValue != null)
+ {
+ propertyProvider.setCameraPropertyValue(IOlyCameraProperty.TAKE_MODE, takeModeValue);
+ Log.v(TAG, "loadCameraSettings() TAKEMODE : " + takeModeValue);
+ setCount++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ Log.v(TAG, "loadCameraSettings() : loadCameraSettingsSequential() fail...");
+ }
+
+ Set<String> names = propertyProvider.getCameraPropertyNames();
+ for (String name : names)
+ {
+ String value = preferences.getString(idHeader + name, null);
+ if (value != null)
+ {
+ if (propertyProvider.canSetCameraProperty(name))
+ {
+ // Read Onlyのプロパティを除外して登録
+ try
+ {
+ // カメラプロパティを個別登録(全パラメータを一括登録すると何か落ちている
+ Log.v(TAG, "loadCameraSettingsSequential(): " + value);
+ propertyProvider.setCameraPropertyValue(name, value);
+ setCount++;
+ //Thread.sleep(5); // 処理落ちしている?かもしれないので必要なら止める
+ ret = true;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ ret = false;
+ }
+ }
+ }
+ }
+ Log.v(TAG, "loadCameraSettingsSequential() : END [" + idHeader + "]" + " " + setCount);
+ }
+ return (ret);
+ }
+
+
+ /**
+ * カメラのプロパティを1つづつ個別設定(違っているものだけ設定する)
+ *
+ */
+ private boolean loadCameraSettingsOnlyDifferences(String idHeader)
+ {
+ boolean ret = false;
+ int setCount = 0;
+
+ // Restores my settings.
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ if (cameraConnection.getConnectionStatus() == ICameraConnection.CameraConnectionStatus.CONNECTED)
+ {
+
+ // 現在の設定値を全部とってくる
+ Map<String, String> propertyValues;
+ try
+ {
+ propertyValues = propertyProvider.getCameraPropertyValues(propertyProvider.getCameraPropertyNames());
+ }
+ catch (Exception e)
+ {
+ // 設定値が取得できなかった場合は、終了する。
+ e.printStackTrace();
+ return (false);
+ }
+ if (propertyValues == null)
+ {
+ // プロパティの取得が失敗していたら、何もせずに折り返す
+ return (false);
+ }
+
+ String takeModeValue = preferences.getString(idHeader + IOlyCameraProperty.TAKE_MODE, null);
+ try
+ {
+ // TAKEMODE だけは先行して設定する(設定できないカメラプロパティもあるので...)
+ if (takeModeValue != null)
+ {
+ propertyProvider.setCameraPropertyValue(IOlyCameraProperty.TAKE_MODE, takeModeValue);
+ Log.v(TAG, "loadCameraSettingsOnlyDifferences() TAKEMODE : " + takeModeValue);
+ setCount++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ Log.v(TAG, "loadCameraSettings() : loadCameraSettingsOnlyDifferences() fail...");
+ }
+
+ Set<String> names = propertyProvider.getCameraPropertyNames();
+ for (String name : names)
+ {
+ String value = preferences.getString(idHeader + name, null);
+ String currentValue = propertyValues.get(name);
+ if ((value != null)&&(currentValue != null)&&(!value.equals(currentValue)))
+ //if (value != null)
+ {
+ if (propertyProvider.canSetCameraProperty(name))
+ {
+ // Read Onlyのプロパティを除外して登録
+ try
+ {
+ // カメラプロパティを個別登録(全パラメータを一括登録すると何か落ちている
+ Log.v(TAG, "loadCameraSettingsOnlyDifferences(): SET : " + value);
+ propertyProvider.setCameraPropertyValue(name, value);
+ setCount++;
+ //Thread.sleep(5); // 処理落ちしている?かもしれないので必要なら止める
+ ret = true;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ ret = false;
+ }
+ }
+ }
+ }
+ Log.v(TAG, "loadCameraSettingsOnlyDifferences() : END [" + idHeader + "]" + " " + setCount);
+ }
+ return (ret);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops;
+
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.DialogFragment;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTabHost;
+import android.support.v4.view.ViewPager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TabHost;
+
+import net.osdn.gokigen.gr2control.R;
+
+
+public class LoadSaveMyCameraPropertyDialog extends DialogFragment implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener, ILoadSaveMyCameraPropertyDialogDismiss
+{
+ private final String TAG = toString();
+ private ILoadSaveCameraProperties propertyOperations = null;
+ private FragmentTabHost tabHost = null;
+ private ViewPager viewPager = null;
+
+ public void setPropertyOperationsHolder(ILoadSaveCameraProperties holder)
+ {
+ propertyOperations = holder;
+ }
+
+ /**/
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+ try
+ {
+ View view = inflater.inflate(R.layout.dialog_my_camera_properties, container);
+ tabHost = view.findViewById(R.id.tabHost01);
+ tabHost.setup(getActivity(), getChildFragmentManager());
+ tabHost.addTab(tabHost.newTabSpec("Load").setIndicator(getString(R.string.title_tab_title_load)), Fragment.class, null);
+ tabHost.addTab(tabHost.newTabSpec("Save").setIndicator(getString(R.string.title_tab_title_save)), Fragment.class, null);
+
+ tabHost.setOnTabChangedListener(this);
+
+ LoadSaveMyCameraPropertyPagerAdapter adapter = new LoadSaveMyCameraPropertyPagerAdapter(getChildFragmentManager(), this);
+ adapter.setTitles(new String[]{getString(R.string.title_tab_title_load), getString(R.string.title_tab_title_save)});
+
+ viewPager = view.findViewById(R.id.pager);
+ viewPager.setAdapter(adapter);
+ //viewPager.setOnPageChangeListener(this);
+ viewPager.addOnPageChangeListener(this);
+
+ getDialog().setTitle(getString(R.string.title_my_settings));
+ return (view);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+
+ }
+
+ @Override
+ public void onTabChanged(String tabId)
+ {
+ Log.v(TAG, "CHANGED TAB : " + tabId);
+
+ int i = tabHost.getCurrentTab();
+ viewPager.setCurrentItem(i);
+ }
+
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+
+ }
+
+ @Override
+ public void onPageSelected(int position)
+ {
+ Log.v(TAG, "CHANGED PAGER : " + position);
+ tabHost.setCurrentTab(position);
+
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int state)
+ {
+
+ }
+
+ @Override
+ public void doDismissWithPropertyLoad(final String id, final String name)
+ {
+ dismiss();
+ if (propertyOperations != null)
+ {
+ propertyOperations.loadCameraSettings(id, name);
+ }
+ }
+
+ @Override
+ public void doDismissWithPropertySave(final String id, final String name)
+ {
+ dismiss();
+ if (propertyOperations != null)
+ {
+ propertyOperations.saveCameraSettings(id, name);
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops;
+
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.util.Log;
+
+class LoadSaveMyCameraPropertyPagerAdapter extends FragmentPagerAdapter
+{
+ private final String TAG = toString();
+ private final ILoadSaveMyCameraPropertyDialogDismiss dismissInterface;
+
+ private String[] titles = null;
+ private LoadMyCameraPropertyFragment loadFragment = null;
+ private SaveMyCameraPropertyFragment saveFragment = null;
+
+ LoadSaveMyCameraPropertyPagerAdapter(FragmentManager fm, ILoadSaveMyCameraPropertyDialogDismiss dismissInterface)
+ {
+ super(fm);
+ this.dismissInterface = dismissInterface;
+ }
+
+ private void initialize()
+ {
+ loadFragment = null;
+ loadFragment = new LoadMyCameraPropertyFragment();
+ loadFragment.setDismissInterface(dismissInterface);
+
+ saveFragment = null;
+ saveFragment = new SaveMyCameraPropertyFragment();
+ saveFragment.setDismissInterface(dismissInterface);
+ }
+
+ @Override
+ public Fragment getItem(int position)
+ {
+ Log.v(TAG, "getItem :" + position);
+ if ((loadFragment == null)||(saveFragment == null))
+ {
+ initialize();
+ }
+ Fragment returnFragment;
+ if (position == 0)
+ {
+ // loadFragment
+ returnFragment = loadFragment;
+ }
+ else //
+ {
+ // saveFragment
+ returnFragment = saveFragment;
+ }
+ return (returnFragment);
+ }
+
+ @Override
+ public int getCount()
+ {
+ return 2;
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position)
+ {
+ return titles[position];
+ }
+
+ void setTitles(String[] titles)
+ {
+ this.titles = titles;
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import java.util.List;
+
+class MyCameraPropertyLoadArrayAdapter extends ArrayAdapter<MyCameraPropertySetItems>
+{
+ private LayoutInflater inflater;
+ private final int textViewResourceId;
+ private List<MyCameraPropertySetItems> listItems;
+
+ MyCameraPropertyLoadArrayAdapter(Context context, int resource, List<MyCameraPropertySetItems> objects)
+ {
+ super(context, resource, objects);
+ textViewResourceId = resource;
+ listItems = objects;
+
+ inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public @NonNull View getView(int position, View convertView, @NonNull ViewGroup parent)
+ {
+ View view;
+ if(convertView != null)
+ {
+ view = convertView;
+ }
+ else
+ {
+ view = inflater.inflate(textViewResourceId, parent, false);
+ }
+ MyCameraPropertySetItems item = listItems.get(position);
+ try
+ {
+ TextView idView = view.findViewWithTag("id");
+ idView.setText(item.getItemId());
+
+ TextView titleView = view.findViewWithTag("title");
+ titleView.setText(item.getItemName());
+
+ TextView infoView = view.findViewWithTag("info");
+ infoView.setText(item.getItemInfo());
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (view);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import net.osdn.gokigen.gr2control.R;
+
+import java.util.List;
+
+class MyCameraPropertySetArrayAdapter extends ArrayAdapter<MyCameraPropertySetItems>
+{
+ private final String TAG = toString();
+ private final Context context;
+ private LayoutInflater inflater;
+ private final int textViewResourceId;
+ private List<MyCameraPropertySetItems> listItems;
+ private final ILoadSaveMyCameraPropertyDialogDismiss dialogDismiss;
+
+
+ MyCameraPropertySetArrayAdapter(Context context, int resource, List<MyCameraPropertySetItems> objects, ILoadSaveMyCameraPropertyDialogDismiss dialogDismiss)
+ {
+ super(context, resource, objects);
+ this.context = context;
+ textViewResourceId = resource;
+ listItems = objects;
+ this.dialogDismiss = dialogDismiss;
+
+ inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public @NonNull View getView(int position, View convertView, @NonNull ViewGroup parent)
+ {
+ View view;
+ if(convertView != null)
+ {
+ view = convertView;
+ }
+ else
+ {
+ view = inflater.inflate(textViewResourceId, parent, false);
+ }
+ try
+ {
+ final MyCameraPropertySetItems item = listItems.get(position);
+
+ TextView idView =view.findViewWithTag("id");
+ idView.setText(item.getItemId());
+
+ final EditText titleView = view.findViewWithTag("title");
+ titleView.setText(item.getItemName());
+
+ TextView infoView = view.findViewWithTag("info");
+ infoView.setText(item.getItemInfo());
+
+ Button button = view.findViewWithTag("button");
+ button.setOnClickListener(new Button.OnClickListener()
+ {
+ @Override
+ public void onClick(View view)
+ {
+
+ String idHeader = item.getItemId();
+ String title = titleView.getText().toString();
+ String itemInfo = item.getItemInfo();
+
+ Log.v(TAG, "CLICKED : " + idHeader + " " + title + " (" + item.getItemName() + " " + itemInfo + ")" );
+ if (dialogDismiss != null)
+ {
+ dialogDismiss.doDismissWithPropertySave(idHeader, title);
+ }
+ Log.v(TAG, "PROPERTY STORED : " + idHeader + " " + title);
+
+ // Toastで保管したことを通知する
+ String restoredMessage = context.getString(R.string.saved_my_props) + title;
+ Toast.makeText(context, restoredMessage, Toast.LENGTH_SHORT).show();
+
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (view);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops;
+
+class MyCameraPropertySetItems
+{
+ private final String itemId;
+ private String itemName;
+ private String itemInfo;
+ private int iconResource;
+
+ MyCameraPropertySetItems(int iconResource, String itemId, String itemName, String itemInfo)
+ {
+ this.iconResource = iconResource;
+ this.itemId = itemId;
+ this.itemName = itemName;
+ this.itemInfo = itemInfo;
+ }
+
+ String getItemId()
+ {
+ return itemId;
+ }
+
+ String getItemName()
+ {
+ return itemName;
+ }
+
+ String getItemInfo()
+ {
+ return itemInfo;
+ }
+
+ int getIconResource()
+ {
+ return iconResource;
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops;
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.v4.app.ListFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import net.osdn.gokigen.gr2control.R;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+public class SaveMyCameraPropertyFragment extends ListFragment
+{
+ private ILoadSaveMyCameraPropertyDialogDismiss dialogDismiss = null;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+ return (inflater.inflate(R.layout.list_camera_properties, container, false));
+ }
+
+ public void setDismissInterface(ILoadSaveMyCameraPropertyDialogDismiss dismiss)
+ {
+ this.dialogDismiss = dismiss;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+
+ List<MyCameraPropertySetItems> listItems = new ArrayList<>();
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+ for (int index = 1; index <= LoadSaveCameraProperties.MAX_STORE_PROPERTIES; index++)
+ {
+ String idHeader = String.format(Locale.ENGLISH, "%03d", index);
+ String prefDate = preferences.getString(idHeader + LoadSaveCameraProperties.DATE_KEY, "");
+ if (prefDate.length() <= 0)
+ {
+ listItems.add(new MyCameraPropertySetItems(0, idHeader, "", ""));
+ break;
+ }
+ String prefTitle = preferences.getString(idHeader + LoadSaveCameraProperties.TITLE_KEY, "");
+ listItems.add(new MyCameraPropertySetItems(0, idHeader, prefTitle, prefDate));
+ }
+ MyCameraPropertySetArrayAdapter adapter = new MyCameraPropertySetArrayAdapter(getActivity(), R.layout.column_save, listItems, dialogDismiss);
+ setListAdapter(adapter);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.operation;
+
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+
+import net.osdn.gokigen.gr2control.R;
+import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
+import net.osdn.gokigen.gr2control.scene.ConfirmationDialog;
+import net.osdn.gokigen.gr2control.scene.IChangeScene;
+
+/**
+ * Preferenceがクリックされた時に処理するクラス
+ *
+ */
+public class CameraPowerOff implements Preference.OnPreferenceClickListener, ConfirmationDialog.Callback
+{
+ private final Context context;
+ private final IChangeScene changeScene;
+ private String preferenceKey = null;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ public CameraPowerOff(Context context, IChangeScene changeScene)
+ {
+ this.context = context;
+ this.changeScene = changeScene;
+ }
+
+ /**
+ * クラスの準備
+ *
+ */
+ public void prepare()
+ {
+ // 何もしない
+ }
+
+ /**
+ *
+ *
+ * @param preference クリックしたpreference
+ * @return false : ハンドルしない / true : ハンドルした
+ */
+ @Override
+ public boolean onPreferenceClick(Preference preference)
+ {
+ if (!preference.hasKey())
+ {
+ return (false);
+ }
+
+ preferenceKey = preference.getKey();
+ if (preferenceKey.contains(IPreferencePropertyAccessor.EXIT_APPLICATION))
+ {
+
+ // 確認ダイアログの生成と表示
+ ConfirmationDialog dialog = ConfirmationDialog.newInstance(context);
+ dialog.show(R.string.dialog_title_confirmation, R.string.dialog_message_power_off, this);
+ return (true);
+ }
+ return (false);
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void confirm()
+ {
+ if (preferenceKey.contains(IPreferencePropertyAccessor.EXIT_APPLICATION))
+ {
+ // カメラの電源をOFFにしたうえで、アプリケーションを終了する。
+ changeScene.exitApplication();
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.operation.takepicture;
+import android.graphics.PointF;
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
+
+/**
+ * オートブラケッティング実行クラス
+ *
+ *
+ * Created by MRSa on 2016/06/18.
+ */
+public class BracketingShotControl implements OLYCamera.TakePictureCallback
+{
+ private final String TAG = toString();
+
+ private static final int BRACKETING_INTERVAL_MILLISECOND = 300; // 撮影待ち時間(ms)
+ private static final int BRACKETING_PROPERTY_VALUE_SET_RETRY = 10;
+
+ private static final int BRACKET_NONE = 0; // 通常のショット
+ private static final int BRACKET_EXPREV = 1; // 露出補正
+ private static final int BRACKET_APERTURE = 2; // 絞り
+ private static final int BRACKET_ISO = 3; // ISO
+ private static final int BRACKET_SHUTTER = 4; // シャッター
+ private static final int BRACKET_WB = 5; // ホワイトバランス
+ private static final int BRACKET_COLOR_TONE = 6; // カラートーン
+
+ private final OLYCamera camera;
+ private final IAutoFocusFrameDisplay autoFocusFrame;
+ private final IIndicatorControl indicator;
+ private boolean isShootingWait = false;
+ private boolean isBracketingAction = false;
+ private int retryUpdateBracketingStatus = 0;
+ private int waitSeconds = 0; // 撮影待ち時間
+
+ private int bracketCount = 0;
+ private String targetPropertyName = null;
+ private String originalProperty = null;
+ private int originalPropertyIndex = -1;
+ private List<String> propertyValueList = null;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ public BracketingShotControl(OLYCamera camera, IAutoFocusFrameDisplay autoFocusFrame, IIndicatorControl indicator)
+ {
+ this.camera = camera;
+ this.autoFocusFrame = autoFocusFrame;
+ this.indicator = indicator;
+ }
+
+ /**
+ * ブラケッティング対象のプロパティの現在設定値と、その選択肢を記憶する
+ *
+ * @param name ブラケッティング対象の名前
+ * @return ブラケッティングの現在設定値
+ */
+ private int prepareBracketProperty(String name)
+ {
+ try
+ {
+ targetPropertyName = name;
+ if (name.length() > 0)
+ {
+ originalProperty = camera.getCameraPropertyValue(name);
+ propertyValueList = camera.getCameraPropertyValueList(name);
+ if (bracketCount < 0)
+ {
+ bracketCount = propertyValueList.size();
+ }
+ return (propertyValueList.indexOf(originalProperty));
+ }
+ else
+ {
+ originalProperty = null;
+ propertyValueList = null;
+ }
+ }
+ catch (Exception e)
+ {
+ originalProperty = null;
+ propertyValueList = null;
+ e.printStackTrace();
+ System.gc();
+ }
+ return (-1);
+ }
+
+
+ /**
+ * ブラケッティング対象のプロパティを特定する
+ *
+ * @param isBracketing プロパティ
+ * @return true : 対象の特定完了 / false : 対象の特定失敗
+ */
+ private boolean decideBracketProperty(int isBracketing)
+ {
+/*
+ switch (isBracketing)
+ {
+ case BRACKET_EXPREV:
+ // 露出ブラケット
+ targetPropertyName = IOlyCameraProperty.EXPOSURE_COMPENSATION;
+ break;
+
+ case BRACKET_APERTURE:
+ // 絞り値設定
+ targetPropertyName = IOlyCameraProperty.APERTURE;
+ break;
+
+ case BRACKET_ISO:
+ // ISO
+ targetPropertyName = IOlyCameraProperty.ISO_SENSITIVITY;
+ break;
+
+ case BRACKET_SHUTTER:
+ // シャッターブラケット
+ targetPropertyName = IOlyCameraProperty.SHUTTER_SPEED;
+ break;
+
+ case BRACKET_WB:
+ // ホワイトバランスブラケット
+ targetPropertyName = IOlyCameraProperty.WB_MODE;
+ bracketCount = -1;
+ break;
+
+ case BRACKET_COLOR_TONE:
+ // ピクチャーモードブラケット
+ targetPropertyName = IOlyCameraProperty.COLOR_TONE;
+ bracketCount = -1;
+ break;
+
+ case BRACKET_NONE:
+ // パラメータは変更しないパターン...
+ targetPropertyName = "";
+ break;
+
+ default:
+ // 何もしない
+ return (false);
+ }
+*/
+ targetPropertyName = "";
+ originalPropertyIndex = prepareBracketProperty(targetPropertyName);
+ return (true);
+ }
+
+
+ /**
+ * 写真撮影(ブラケッティング撮影)を開始する
+ * bracketingStyle : ブラケッティングスタイル
+ * bracketingCount : 撮影枚数
+ * durationSeconds : 撮影間隔(単位:秒)
+ */
+ public void startShootBracketing(int bracketingStyle, int bracketingCount, int durationSeconds)
+ {
+ if ((camera.isTakingPicture())||(camera.isRecordingVideo())||(isBracketingAction))
+ {
+ // スチル or ムービー撮影中、ブラケッティング撮影中なら、何もしない
+ return;
+ }
+
+ // ブラケッティング撮影の準備
+ bracketCount = bracketingCount;
+ if (!decideBracketProperty(bracketingStyle))
+ {
+ // ブラケッティング指定ではないので、何もせずに終了する
+ return;
+ }
+
+ // 撮影間隔 (単位:秒)
+ waitSeconds = durationSeconds;
+
+ // ブラケッティング撮影開始! (別スレッドでブラケッティング撮影を開始する)
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ executor.submit(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ isBracketingAction = true;
+ indicator.onBracketingStatusUpdate("INT");
+ try
+ {
+ startBracket();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ isBracketingAction = false;
+ indicator.onBracketingStatusUpdate("");
+ }
+ });
+ }
+
+ /**
+ * ブラケッティング撮影を開始する
+ * (これは別スレッドで処理する)
+ *
+ * 一番小さい選択肢(インデックス)から設定された撮影枚数分、
+ * 徐々に選択肢をずらして撮影する。
+ *
+ */
+ private void startBracket()
+ {
+ int startIndex = originalPropertyIndex - (bracketCount / 2);
+ if (propertyValueList != null)
+ {
+ if ((startIndex + bracketCount) > propertyValueList.size())
+ {
+ startIndex = propertyValueList.size() - bracketCount;
+ }
+ }
+ if (startIndex < 0)
+ {
+ startIndex = 0;
+ }
+
+ PointF afPoint = camera.getActualAutoFocusPoint();
+ for (int index = 0; index < bracketCount; index++)
+ {
+ // 撮影条件を更新する
+ updateBracketingStatus(index, startIndex);
+ startIndex++;
+
+ try
+ {
+ // AFポイントを設定する
+ if (afPoint != null)
+ {
+ camera.setAutoFocusPoint(afPoint);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ if (bracketCount == 1)
+ {
+ // 1枚しか撮影しない時は、撮影前にウェイトをかける
+ waitSeconds(waitSeconds);
+ }
+
+ try
+ {
+ // 写真を撮影する
+ camera.takePicture(new HashMap<String, Object>(), this);
+ isShootingWait = true;
+ while (isShootingWait)
+ {
+ // ここで撮影状態が整うまで少し待つ
+ Thread.sleep(BRACKETING_INTERVAL_MILLISECOND);
+ updateShootingWaitStatus();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ // 指定された時間待機、ただし、最後の撮影が終わったあとには待たないようにする。
+ if ((index + 1) < bracketCount)
+ {
+ waitSeconds(waitSeconds);
+ }
+ }
+ try
+ {
+ // 変更したプロパティ値を元の値に戻す...ちょっと待ってから
+ Thread.sleep(BRACKETING_INTERVAL_MILLISECOND);
+ if (originalProperty != null)
+ {
+ camera.setCameraPropertyValue(targetPropertyName, originalProperty);
+ }
+
+ // とにかくAF枠を消す。
+ camera.clearAutoFocusPoint();
+ autoFocusFrame.hideFocusFrame();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 指定された時間待機する
+ *
+ * @param seconds 待機秒数
+ */
+ private void waitSeconds(int seconds)
+ {
+ for (int count = seconds; count > 0; count--)
+ {
+ // 待ち時間(単位:秒)
+ try
+ {
+ // BKT表示(撮影枚数表示と待ち時間)を変える
+ indicator.onBracketingStatusUpdate("WAIT " + count + "sec.");
+ Thread.sleep(1000);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ indicator.onBracketingStatusUpdate("");
+ }
+
+ /**
+ * ブラケッティング撮影の状態を更新する
+ *
+ * @param index 撮影が終了したカウント(0始まり)
+ */
+ private void updateBracketingStatus(int index, int currentIndex)
+ {
+ Log.v(TAG, "updateBracketingStatus() : " + index + "(" + currentIndex + ")");
+
+ // カメラのプロパティ設定を変える
+ try
+ {
+ if (propertyValueList != null)
+ {
+ Thread.sleep(BRACKETING_INTERVAL_MILLISECOND);
+ camera.setCameraPropertyValue(targetPropertyName, propertyValueList.get(currentIndex));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+
+ // 頭に来たので、再度呼ぶ (リトライオーバーするまで)
+ if (retryUpdateBracketingStatus < BRACKETING_PROPERTY_VALUE_SET_RETRY)
+ {
+ retryUpdateBracketingStatus++;
+ updateBracketingStatus(index, currentIndex);
+ }
+ }
+ retryUpdateBracketingStatus = 0;
+
+ // 撮影枚数表示を変える
+ indicator.onBracketingStatusUpdate("INT " + (index + 1) + "/" + bracketCount);
+ }
+
+ /**
+ * カメラの状態を取得し、撮影可能か確認する。
+ * (trueならまだ撮影処理中、falseなら撮影可能)
+ */
+ private void updateShootingWaitStatus()
+ {
+ boolean isBusy = false;
+ try
+ {
+ isBusy = ((camera.isTakingPicture())||(camera.isMediaBusy())||(camera.isRecordingVideo()));
+
+ // ちょっと待ち時間をとりたい...
+ String messageToShow = "getShootingBusyStatus() : " + String.valueOf(isBusy);
+ Log.v(TAG, messageToShow);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ isShootingWait = isBusy;
+ }
+
+ /**
+ * OLYCamera.TakePictureCallback の実装
+ *
+ *
+ */
+ @Override
+ public void onProgress(OLYCamera olyCamera, OLYCamera.TakingProgress takingProgress, OLYCameraAutoFocusResult olyCameraAutoFocusResult)
+ {
+ // 特に何もしないでおこう
+ }
+
+ /**
+ * OLYCamera.TakePictureCallback の実装
+ *
+ */
+ @Override
+ public void onCompleted()
+ {
+ // 撮影待ち状態の更新
+ updateShootingWaitStatus();
+ }
+
+ /**
+ * OLYCamera.TakePictureCallback の実装
+ *
+ * @param e 例外情報
+ */
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ e.printStackTrace();
+
+ // 撮影待ち状態の更新
+ updateShootingWaitStatus();
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.operation.takepicture;
+
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
+
+import java.util.HashMap;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraKitException;
+
+
+/**
+ * ビデオ撮影の開始・終了制御クラス。
+ *
+ */
+public class MovieRecordingControl implements OLYCamera.CompletedCallback
+{
+ private final String TAG = toString();
+ // private final Context context;
+ private final OLYCamera camera;
+ private final IIndicatorControl indicator;
+ private IIndicatorControl.shootingStatus isRecordingStart = IIndicatorControl.shootingStatus.Unknown;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ //public MovieRecordingControl(Context context, OLYCamera camera, IIndicatorControl indicator)
+ public MovieRecordingControl(OLYCamera camera, IIndicatorControl indicator)
+ {
+ //this.context = context;
+ this.camera = camera;
+ this.indicator = indicator;
+ }
+
+ /**
+ * 動画撮影の開始と終了
+ *
+ */
+ public void movieControl()
+ {
+ try
+ {
+ Log.v(TAG, "MovieRecordingControl::movieControl()");
+ if (camera.isTakingPicture())
+ {
+ // スチル撮影中の場合は、何もしない(モード異常なので)
+ Log.v(TAG, "NOW TAKING PICTURE(STILL) : COMMAND IGNORED");
+ return;
+ }
+
+ if (!camera.isRecordingVideo())
+ {
+ // ムービー撮影の開始指示
+ camera.startRecordingVideo(new HashMap<String, Object>(), this);
+ isRecordingStart = IIndicatorControl.shootingStatus.Starting;
+ }
+ else
+ {
+ // ムービー撮影の終了指示
+ camera.stopRecordingVideo(this);
+ isRecordingStart = IIndicatorControl.shootingStatus.Stopping;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 処理完了
+ *
+ */
+ @Override
+ public void onCompleted()
+ {
+ try
+ {
+ Log.v(TAG, "MovieRecordingControl::onCompleted()");
+ // 撮影終了をバイブレータで知らせる
+ //statusDrawer.vibrate(IShowInformation.VIBRATE_PATTERN_SIMPLE_MIDDLE);
+ indicator.onMovieStatusUpdate(isRecordingStart);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * エラー発生
+ *
+ * @param e 例外情報
+ */
+ @Override
+ public void onErrorOccurred(OLYCameraKitException e)
+ {
+ // 撮影失敗をバイブレータで知らせる
+ //statusDrawer.vibrate(IShowInformation.VIBRATE_PATTERN_SIMPLE_SHORT);
+ {
+ //// 撮影失敗の表示をToastで行う
+ //Toast.makeText(context, R.string.video_failure, Toast.LENGTH_SHORT).show();
+ Log.v(TAG, "MovieControl::onErrorOccurred()");
+ isRecordingStart = IIndicatorControl.shootingStatus.Unknown;
+ indicator.onMovieStatusUpdate(isRecordingStart);
+ }
+ e.printStackTrace();
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.operation.takepicture;
+
+import android.graphics.PointF;
+import android.graphics.RectF;
+
+import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
+import jp.co.olympus.camerakit.OLYCameraKitException;
+
+
+/**
+ * オートフォーカス制御クラス
+ *
+ * 1. setAutoFocusFrameDisplay() で AFフレームの表示クラスを設定
+ * 2. lockAutoFocus() で AF-Lockを実行
+ * 3. unlockAutoFocus() で AF-Unlock を実行
+ *
+ */
+public class OlympusAutoFocusControl implements OLYCamera.TakePictureCallback
+{
+ private final OLYCamera camera;
+ private final IIndicatorControl indicator;
+
+ private IAutoFocusFrameDisplay frameDisplayer;
+ private RectF focusFrameRect = null;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ public OlympusAutoFocusControl(OLYCamera camera, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ {
+ this.camera = camera;
+ this.frameDisplayer = frameDisplayer;
+ this.indicator = indicator;
+ }
+
+ /**
+ * オートフォーカスを駆動させ、ロックする
+ *
+ * @param point ターゲットAF点
+ *
+ */
+ public boolean lockAutoFocus(PointF point)
+ {
+ if (camera.isTakingPicture() || camera.isRecordingVideo())
+ {
+ // 撮影中の場合にはフォーカスロックはやらない。
+ return (false);
+ }
+
+ RectF preFocusFrameRect = getPreFocusFrameRect(point);
+ showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Running, 0.0);
+
+ try
+ {
+ // Set auto-focus point.
+ camera.setAutoFocusPoint(point);
+
+ // Lock auto-focus.
+ focusFrameRect = preFocusFrameRect;
+ camera.lockAutoFocus(this);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ // Lock failed.
+ try
+ {
+ camera.clearAutoFocusPoint();
+ camera.unlockAutoFocus();
+ showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Failed, 1.0);
+ }
+ catch (Exception ee)
+ {
+ ee.printStackTrace();
+ }
+ return (false);
+ }
+ return (true);
+ }
+
+ /**
+ * AF-Lを解除する
+ *
+ */
+ public void unlockAutoFocus()
+ {
+ if (camera.isTakingPicture() || camera.isRecordingVideo())
+ {
+ // 撮影中の場合には、フォーカスロック解除はやらない
+ return;
+ }
+
+ // Unlock auto-focus.
+ try
+ {
+ camera.unlockAutoFocus();
+ camera.clearAutoFocusPoint();
+ hideFocusFrame();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onProgress(OLYCamera olyCamera, OLYCamera.TakingProgress takingProgress, OLYCameraAutoFocusResult olyCameraAutoFocusResult)
+ {
+ if (takingProgress == OLYCamera.TakingProgress.EndFocusing)
+ {
+ if (olyCameraAutoFocusResult.getResult().equals("ok") && olyCameraAutoFocusResult.getRect() != null)
+ {
+ // Lock succeed.
+ RectF postFocusFrameRect = olyCameraAutoFocusResult.getRect();
+ showFocusFrame(postFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Focused, 0.0);
+
+ }
+ else if (olyCameraAutoFocusResult.getResult().equals("none"))
+ {
+ // Could not lock.
+ try
+ {
+ camera.clearAutoFocusPoint();
+ camera.unlockAutoFocus();
+ }
+ catch (OLYCameraKitException ee)
+ {
+ ee.printStackTrace();
+ }
+ hideFocusFrame();
+ }
+ else
+ {
+ // Lock failed.
+ try
+ {
+ camera.clearAutoFocusPoint();
+ camera.unlockAutoFocus();
+ }
+ catch (OLYCameraKitException ee)
+ {
+ ee.printStackTrace();
+ }
+ showFocusFrame(focusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Failed, 1.0);
+ }
+ }
+ }
+
+ @Override
+ public void onCompleted()
+ {
+ // フォーカスロック成功、なにもしない
+ }
+
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ // フォーカスロック失敗 : 通知される
+ e.printStackTrace();
+ try
+ {
+ camera.clearAutoFocusPoint();
+ camera.unlockAutoFocus();
+ hideFocusFrame();
+ }
+ catch (Exception ee)
+ {
+ ee.printStackTrace();
+ }
+ showFocusFrame(focusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Errored, 1.0);
+ }
+
+ private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
+ {
+ if (frameDisplayer != null)
+ {
+ frameDisplayer.showFocusFrame(rect, status, duration);
+ }
+ indicator.onAfLockUpdate(IAutoFocusFrameDisplay.FocusFrameStatus.Focused == status);
+ }
+
+ private void hideFocusFrame()
+ {
+ if (frameDisplayer != null)
+ {
+ frameDisplayer.hideFocusFrame();
+ }
+ indicator.onAfLockUpdate(false);
+ }
+
+ private RectF getPreFocusFrameRect(PointF point)
+ {
+ float imageWidth = 1.0f;
+ float imageHeight = 1.0f;
+ if (frameDisplayer != null)
+ {
+ imageWidth = frameDisplayer.getContentSizeWidth();
+ imageHeight = frameDisplayer.getContentSizeHeight();
+ }
+ // Display a provisional focus frame at the touched point.
+ float focusWidth = 0.125f; // 0.125 is rough estimate.
+ float focusHeight = 0.125f;
+ if (imageWidth > imageHeight)
+ {
+ focusHeight *= (imageWidth / imageHeight);
+ }
+ else
+ {
+ focusHeight *= (imageHeight / imageWidth);
+ }
+ return (new RectF(point.x - focusWidth / 2.0f, point.y - focusHeight / 2.0f,
+ point.x + focusWidth / 2.0f, point.y + focusHeight / 2.0f));
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.operation.takepicture;
+
+import android.graphics.RectF;
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
+
+/**
+ * 連続撮影用のクラス
+ *
+ */
+public class SequentialShotControl implements OLYCamera.TakePictureCallback
+{
+ private final String TAG = toString();
+ //private final Context context;
+ private final OLYCamera camera;
+ private final IIndicatorControl indicator;
+ private IAutoFocusFrameDisplay frameDisplayer;
+
+ private IIndicatorControl.shootingStatus currentStatus = IIndicatorControl.shootingStatus.Unknown;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ //public SequentialShotControl(Context context, OLYCamera camera, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ public SequentialShotControl(OLYCamera camera, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ {
+ //this.context = context;
+ this.camera = camera;
+ this.frameDisplayer = frameDisplayer;
+ this.indicator = indicator;
+ }
+
+ /**
+ * 撮影の開始と終了
+ *
+ */
+ public void shotControl()
+ {
+ if (camera.isRecordingVideo())
+ {
+ // ビデオ撮影中の場合は、何もしない(モード異常なので)
+ return;
+ }
+ try
+ {
+ if (!camera.isTakingPicture())
+ {
+ // 連続撮影の開始
+ currentStatus = IIndicatorControl.shootingStatus.Starting;
+ camera.startTakingPicture(null, this);
+ indicator.onShootingStatusUpdate(currentStatus);
+ }
+ else
+ {
+ // 連続撮影の終了
+ currentStatus = IIndicatorControl.shootingStatus.Stopping;
+ camera.stopTakingPicture(this);
+ indicator.onShootingStatusUpdate(currentStatus);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onProgress(OLYCamera olyCamera, OLYCamera.TakingProgress takingProgress, OLYCameraAutoFocusResult olyCameraAutoFocusResult)
+ {
+ if (currentStatus == IIndicatorControl.shootingStatus.Stopping)
+ {
+ // 終了中の時にはなにもしない
+ return;
+ }
+
+ // 撮影中の更新処理
+ if (takingProgress != OLYCamera.TakingProgress.EndFocusing)
+ {
+ return;
+ }
+
+ String result = olyCameraAutoFocusResult.getResult();
+ if (result == null)
+ {
+ Log.v(TAG, "FocusResult is null.");
+ }
+ else switch (result)
+ {
+ case "ok":
+ RectF postFocusFrameRect = olyCameraAutoFocusResult.getRect();
+ if (postFocusFrameRect != null)
+ {
+ showFocusFrame(postFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Focused, 0.0);
+ }
+ break;
+
+ case "none":
+ default:
+ hideFocusFrame();
+ break;
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onCompleted()
+ {
+ Log.v(TAG, "SequentialShotControl::onCompleted()");
+ indicator.onShootingStatusUpdate(currentStatus);
+ if (currentStatus != IIndicatorControl.shootingStatus.Stopping)
+ {
+ // 撮影停止中以外ではなにもしない。
+ return;
+ }
+
+ // 撮影停止処理...
+ try
+ {
+ camera.clearAutoFocusPoint();
+ hideFocusFrame();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ currentStatus = IIndicatorControl.shootingStatus.Unknown;
+ indicator.onShootingStatusUpdate(currentStatus);
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ try
+ {
+ camera.clearAutoFocusPoint();
+ hideFocusFrame();
+ }
+ catch (Exception ee)
+ {
+ ee.printStackTrace();
+ }
+ e.printStackTrace();
+ currentStatus = IIndicatorControl.shootingStatus.Unknown;
+ }
+
+ /**
+ *
+ *
+ */
+ private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
+ {
+ if (frameDisplayer != null)
+ {
+ frameDisplayer.showFocusFrame(rect, status, duration);
+ }
+ indicator.onAfLockUpdate(IAutoFocusFrameDisplay.FocusFrameStatus.Focused == status);
+ }
+
+ /**
+ *
+ *
+ */
+ private void hideFocusFrame()
+ {
+ if (frameDisplayer != null)
+ {
+ frameDisplayer.hideFocusFrame();
+ }
+ indicator.onAfLockUpdate(false);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.operation.takepicture;
+
+import android.graphics.RectF;
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
+
+import java.util.HashMap;
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
+
+
+/**
+ * 一枚撮影用のクラス
+ *
+ * Created by MRSa on 2016/06/18.
+ */
+public class SingleShotControl implements OLYCamera.TakePictureCallback
+{
+ private final String TAG = toString();
+ private final OLYCamera camera;
+ private final IIndicatorControl indicator;
+
+ private IAutoFocusFrameDisplay frameDisplayer;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ public SingleShotControl(OLYCamera camera, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ {
+ this.camera = camera;
+ this.frameDisplayer = frameDisplayer;
+ this.indicator = indicator;
+ }
+
+ /**
+ * 1枚撮影する
+ *
+ */
+ public void singleShot()
+ {
+ try
+ {
+ camera.takePicture(new HashMap<String, Object>(), this);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onProgress(OLYCamera olyCamera, OLYCamera.TakingProgress takingProgress, OLYCameraAutoFocusResult olyCameraAutoFocusResult)
+ {
+ if (takingProgress != OLYCamera.TakingProgress.EndFocusing)
+ {
+ return;
+ }
+
+ String result = olyCameraAutoFocusResult.getResult();
+ if (result == null)
+ {
+ Log.v(TAG, "FocusResult is null.");
+ }
+ else switch (result)
+ {
+ case "ok":
+ RectF postFocusFrameRect = olyCameraAutoFocusResult.getRect();
+ if (postFocusFrameRect != null)
+ {
+ showFocusFrame(postFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Focused, 0.0);
+ }
+ break;
+
+ case "none":
+ default:
+ hideFocusFrame();
+ break;
+ }
+ }
+
+ @Override
+ public void onCompleted()
+ {
+ try
+ {
+ camera.clearAutoFocusPoint();
+ hideFocusFrame();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ try
+ {
+ camera.clearAutoFocusPoint();
+ hideFocusFrame();
+ }
+ catch (Exception ee)
+ {
+ ee.printStackTrace();
+ }
+ e.printStackTrace();
+ //control.presentMessage(R.string.shutter_control_take_failed, e.getMessage());
+ }
+
+ private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
+ {
+ indicator.onAfLockUpdate(IAutoFocusFrameDisplay.FocusFrameStatus.Focused == status);
+ }
+
+ private void hideFocusFrame()
+ {
+ if (frameDisplayer != null)
+ {
+ frameDisplayer.hideFocusFrame();
+ }
+ indicator.onAfLockUpdate(false);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper;
+
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.camera.ICameraInformation;
+import net.osdn.gokigen.gr2control.camera.IFocusingModeNotify;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.property.IOlyCameraProperty;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraPropertyListener;
+
+/**
+ *
+ *
+ */
+public class OLYCameraPropertyListenerImpl implements OLYCameraPropertyListener, ICameraInformation
+{
+ private final String TAG = toString();
+ private final OLYCamera camera;
+ private IFocusingModeNotify focusCallback = null;
+
+ /**
+ *
+ *
+ */
+ OLYCameraPropertyListenerImpl(OLYCamera olyCamera)
+ {
+ olyCamera.setCameraPropertyListener(this);
+ this.camera = olyCamera;
+ }
+
+ /**
+ *
+ *
+ */
+ public void setFocusingControl(IFocusingModeNotify focusCallback)
+ {
+ this.focusCallback = focusCallback;
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onUpdateCameraProperty(final OLYCamera olyCamera, final String name)
+ {
+ Thread thread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ switch (name)
+ {
+ case IOlyCameraProperty.FOCUS_STILL:
+ //
+ Log.v(TAG, "onUpdateCameraProperty() : " + name);
+ if (focusCallback != null)
+ {
+ focusCallback.changedFocusingMode();
+ }
+ break;
+
+ default:
+ //
+ break;
+ }
+ }
+ });
+ try
+ {
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * フォーカス状態を知る(MF or AF)
+ * @return true : MF / false : AF
+ */
+ @Override
+ public boolean isManualFocus()
+ {
+ boolean isManualFocus = false;
+ try
+ {
+ String value = camera.getCameraPropertyValue(IOlyCameraProperty.FOCUS_STILL);
+ Log.v(TAG, "OlyCameraPropertyProxy::isManualFocus() " + value);
+ isManualFocus = !(value.contains("AF"));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (isManualFocus);
+ }
+
+ /**
+ * 電動ズーム機能を持つレンズが装着されているか確認
+ *
+ * @return true ; 電動ズーム付き / false : 電動ズームなし
+ */
+ @Override
+ public boolean isElectricZoomLens()
+ {
+ return ((camera != null)&&(camera.getLensMountStatus()).contains("electriczoom"));
+ }
+
+ /**
+ * AE ロック状態を知る
+ *
+ * @return true : AE Lock / false : AE Unlock
+ */
+ @Override
+ public boolean isExposureLocked()
+ {
+ boolean isExposureLocked =false;
+ try
+ {
+ String value = camera.getCameraPropertyValue(IOlyCameraProperty.AE_LOCK_STATE);
+ Log.v(TAG, "OlyCameraPropertyProxy::isExposureLocked() " + value);
+ isExposureLocked = !(value.contains("UNLOCK"));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (isExposureLocked);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper;
+
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.camera.ICaptureControl;
+import net.osdn.gokigen.gr2control.camera.olympus.operation.takepicture.SingleShotControl;
+import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
+
+public class OlyCameraCaptureControl implements ICaptureControl
+{
+ private final String TAG = toString();
+ private final SingleShotControl singleShotControl;
+
+ OlyCameraCaptureControl(OlyCameraWrapper wrapper, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ {
+ singleShotControl = new SingleShotControl(wrapper.getOLYCamera(), frameDisplayer, indicator);
+ }
+
+ /**
+ * 撮影する
+ *
+ */
+ @Override
+ public void doCapture(int kind)
+ {
+ Log.v(TAG, "doCapture() : " + kind);
+ try
+ {
+ singleShotControl.singleShot();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper;
+
+import android.graphics.PointF;
+import android.view.MotionEvent;
+
+import net.osdn.gokigen.gr2control.camera.IFocusingControl;
+import net.osdn.gokigen.gr2control.camera.olympus.operation.takepicture.OlympusAutoFocusControl;
+import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
+
+/**
+ *
+ *
+ */
+public class OlyCameraFocusControl implements IFocusingControl
+{
+ private final OlympusAutoFocusControl afControl;
+ private final IAutoFocusFrameDisplay frameDisplay;
+
+ OlyCameraFocusControl(OlyCameraWrapper wrapper, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
+ {
+ this.frameDisplay = frameDisplayer;
+ afControl = new OlympusAutoFocusControl(wrapper.getOLYCamera(), frameDisplayer, indicator);
+ }
+
+ @Override
+ public boolean driveAutoFocus(final MotionEvent motionEvent)
+ {
+ if (motionEvent.getAction() != MotionEvent.ACTION_DOWN)
+ {
+ return (false);
+ }
+
+ if (frameDisplay != null)
+ {
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ PointF point = frameDisplay.getPointWithEvent(motionEvent);
+ if (frameDisplay.isContainsPoint(point))
+ {
+ afControl.lockAutoFocus(point);
+ }
+ }
+ });
+ try
+ {
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return (false);
+ }
+
+ @Override
+ public void unlockAutoFocus()
+ {
+ try
+ {
+ afControl.unlockAutoFocus();
+ frameDisplay.hideFocusFrame();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper;
+
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.camera.ICameraHardwareStatus;
+
+import java.util.Map;
+
+import jp.co.olympus.camerakit.OLYCamera;
+
+/**
+ *
+ */
+public class OlyCameraHardwareStatus implements ICameraHardwareStatus
+{
+ private final String TAG = toString();
+ private final OLYCamera camera;
+
+ /**
+ *
+ */
+ OlyCameraHardwareStatus(OLYCamera camera)
+ {
+ this.camera = camera;
+ }
+
+ @Override
+ public boolean isAvailableHardwareStatus()
+ {
+ return (true);
+ }
+
+ @Override
+ public String getLensMountStatus()
+ {
+ String message;
+ try
+ {
+ message = camera.getLensMountStatus();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ message = "[UNKNOWN]";
+ }
+ return (message);
+ }
+
+ @Override
+ public String getMediaMountStatus()
+ {
+ String message;
+ try
+ {
+ message = camera.getMediaMountStatus();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ message = "[UNKNOWN]";
+ }
+ return (message);
+ }
+
+ @Override
+ public float getMinimumFocalLength()
+ {
+ float value;
+ try
+ {
+ value = camera.getMinimumFocalLength();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ value = -1.0f;
+ }
+ return (value);
+ }
+
+ @Override
+ public float getMaximumFocalLength()
+ {
+ float value;
+ try
+ {
+ value = camera.getMaximumFocalLength();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ value = -1.0f;
+ }
+ return (value);
+ }
+
+ @Override
+ public float getActualFocalLength()
+ {
+ float value;
+ try
+ {
+ value = camera.getActualFocalLength();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ value = -1.0f;
+ }
+ return (value);
+ }
+
+ @Override
+ public Map<String, Object> inquireHardwareInformation()
+ {
+ try
+ {
+ return (camera.inquireHardwareInformation());
+ }
+ catch (Exception e)
+ {
+ Log.v(TAG, "EXCEPTION : " + e.toString());
+ e.printStackTrace();
+ }
+ return (null);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper;
+
+import android.support.annotation.NonNull;
+
+import net.osdn.gokigen.gr2control.camera.ICameraStatus;
+import net.osdn.gokigen.gr2control.camera.ICameraStatusWatcher;
+import net.osdn.gokigen.gr2control.liveview.ICameraStatusUpdateNotify;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import jp.co.olympus.camerakit.OLYCamera;
+
+public class OlyCameraStatusWrapper implements ICameraStatus, ICameraStatusWatcher
+{
+ private final OLYCamera camera;
+ private ICameraStatusUpdateNotify updateReceiver = null;
+
+ OlyCameraStatusWrapper(OLYCamera camera)
+ {
+ this.camera = camera;
+ }
+
+
+ @Override
+ public @NonNull List<String> getStatusList(@NonNull String key)
+ {
+ List<String> array = new ArrayList<>();
+
+ // OPC用に変更...
+/*
+ String BATTERY = "battery";
+ String STATE = "state";
+ String FOCUS_MODE = "focusMode";
+ String AF_MODE = "AFMode";
+
+ String RESOLUTION = "reso";
+ String DRIVE_MODE = "shootMode";
+ String WHITE_BALANCE = "WBMode";
+ String AE = "meteringMode";
+
+ String EFFECT = "effect";
+ String TAKE_MODE = "exposureMode";
+ String IMAGESIZE = "stillSize";
+ String MOVIESIZE = "movieSize";
+
+ String APERATURE = "av";
+ String SHUTTER_SPEED = "tv";
+ String ISO_SENSITIVITY = "sv";
+ String EXPREV = "xv";
+ String FLASH_XV = "flashxv";
+*/
+ return (array);
+ }
+
+ @Override
+ public String getStatus(@NonNull String key)
+ {
+ return ("");
+ }
+
+ @Override
+ public void setStatus(@NonNull String key, @NonNull String value)
+ {
+
+ }
+
+ @Override
+ public void startStatusWatch(@NonNull ICameraStatusUpdateNotify notifier)
+ {
+ this.updateReceiver = notifier;
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void stoptStatusWatch()
+ {
+ this.updateReceiver = null;
+
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper;
+
+import android.app.Activity;
+import android.content.SharedPreferences;
+import android.graphics.PointF;
+import android.support.annotation.NonNull;
+import android.support.v7.preference.PreferenceManager;
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
+import net.osdn.gokigen.gr2control.camera.ILiveViewControl;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.property.CameraPropertyUtilities;
+import net.osdn.gokigen.gr2control.liveview.liveviewlistener.IImageDataReceiver;
+import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
+import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
+
+import java.util.Map;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraLiveViewListener;
+
+/**
+ *
+ *
+ */
+class OlyCameraWrapper implements ICameraRunMode, ILiveViewControl, ILiveViewListener, OLYCameraLiveViewListener
+{
+ private final String TAG = toString();
+ private final Activity context;
+ private final OLYCamera camera;
+ private IImageDataReceiver dataReceiver = null;
+
+ /**
+ *
+ *
+ */
+ OlyCameraWrapper(Activity context)
+ {
+ this.context = context;
+ camera = new OLYCamera();
+ camera.setContext(context.getApplicationContext());
+ }
+
+ /**
+ *
+ *
+ */
+ OLYCamera getOLYCamera()
+ {
+ return (camera);
+ }
+
+ /**
+ * ICameraRunMode の実装
+ *
+ */
+ @Override
+ public void changeRunMode(boolean isRecording)
+ {
+ OLYCamera.RunMode runMode = (isRecording) ? OLYCamera.RunMode.Recording : OLYCamera.RunMode.Playback;
+ Log.v(TAG, "changeRunMode() : " + runMode);
+ try
+ {
+ camera.changeRunMode(runMode);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public boolean isRecordingMode()
+ {
+ boolean isRecordingMode = false;
+ try
+ {
+ OLYCamera.RunMode runMode = camera.getRunMode();
+ isRecordingMode = (runMode == OLYCamera.RunMode.Recording);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (isRecordingMode);
+ }
+
+
+ /**
+ * ILiveViewControl の実装
+ *
+ */
+ @Override
+ public void changeLiveViewSize(String size)
+ {
+ try
+ {
+ camera.changeLiveViewSize(CameraPropertyUtilities.toLiveViewSizeType(size));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void startLiveView(boolean isCameraScreen)
+ {
+ Log.v(TAG, "startLiveView() : " + isCameraScreen);
+ try
+ {
+ camera.startLiveView();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void stopLiveView()
+ {
+ try
+ {
+ camera.stopLiveView();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * ライブビューを拡大する
+ *
+ */
+ @Override
+ public void updateDigitalZoom()
+ {
+ try
+ {
+ float scale = getDigitalZoomScalePreference();
+ camera.changeDigitalZoomScale(scale);
+ Log.v(TAG, "DIGITAL ZOOM SCALE : " + scale);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * ライブビューを拡大する
+ *
+ */
+ @Override
+ public void updateMagnifyingLiveViewScale(boolean isChangeScale)
+ {
+ try
+ {
+ updateMagnifyingLiveViewScale(getMagnifyingLiveViewScale(isChangeScale));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * ライブビューのサイズ
+ *
+ * @return ライブビュー倍率
+ */
+ @Override
+ public float getMagnifyingLiveViewScale()
+ {
+ return (getMagnifyingLiveViewScale(false));
+ }
+
+ /**
+ * デジタルズームの倍率を取得する
+ *
+ */
+ @Override
+ public float getDigitalZoomScale()
+ {
+ return (getDigitalZoomScalePreference());
+ }
+
+ /**
+ *
+ *
+ */
+ private void updateMagnifyingLiveViewScale(float scale)
+ {
+ try
+ {
+ if (scale < 5.0f)
+ {
+ if (camera.isMagnifyingLiveView())
+ {
+ camera.stopMagnifyingLiveView();
+ Log.v(TAG, "RESET LIVE VIEW SCALE : " + 1.0f);
+ }
+ return;
+ }
+ OLYCamera.MagnifyingLiveViewScale setScale;
+ if (scale >= 14.0f)
+ {
+ setScale = OLYCamera.MagnifyingLiveViewScale.X14;
+ }
+ else if (scale >= 10.0f)
+ {
+ setScale = OLYCamera.MagnifyingLiveViewScale.X10;
+ }
+ else if (scale >= 7.0f)
+ {
+ setScale = OLYCamera.MagnifyingLiveViewScale.X7;
+ }
+ else // if (scale >= 5.0f)
+ {
+ setScale = OLYCamera.MagnifyingLiveViewScale.X5;
+ }
+ changeMagnifyingLiveView(setScale);
+ Log.v(TAG, "SET LIVE VIEW SCALE : " + scale);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * ライブビューの中心を拡大する
+ *
+ */
+ private void changeMagnifyingLiveView(OLYCamera.MagnifyingLiveViewScale setScale)
+ {
+ try
+ {
+ PointF centerPoint = new PointF(0.5f, 0.5f); // 中心座標
+ if (camera.isMagnifyingLiveView())
+ {
+ camera.changeMagnifyingLiveViewScale(setScale);
+ }
+ else
+ {
+ camera.startMagnifyingLiveViewAtPoint(centerPoint, setScale);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * ライブビュー拡大倍率の設定値を応答する
+ *
+ */
+ private float getMagnifyingLiveViewScale(boolean isChangeScale)
+ {
+ float scale;
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ String value = preferences.getString(IPreferencePropertyAccessor.MAGNIFYING_LIVE_VIEW_SCALE, IPreferencePropertyAccessor.MAGNIFYING_LIVE_VIEW_SCALE_DEFAULT_VALUE);
+ try
+ {
+ scale = Float.parseFloat(value);
+ String changeValue = null;
+ if(isChangeScale)
+ {
+ if (scale >= 14.0f)
+ {
+ scale = 1.0f;
+ changeValue = "1.0";
+ }
+ else if (scale >= 10.0f)
+ {
+ scale = 14.0f;
+ changeValue = "14.0";
+ }
+ else if (scale >= 7.0f)
+ {
+ scale = 10.0f;
+ changeValue = "10.0";
+ }
+ else if (scale >= 5.0f)
+ {
+ scale = 7.0f;
+ changeValue = "7.0";
+ }
+ else // if (scale < 5.0f)
+ {
+ scale = 5.0f;
+ changeValue = "5.0";
+ }
+ }
+ if (changeValue != null)
+ {
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putString(IPreferencePropertyAccessor.MAGNIFYING_LIVE_VIEW_SCALE, changeValue);
+ editor.apply();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ scale = 1.0f;
+ }
+ return (scale);
+ }
+
+ /**
+ * デジタルズーム倍率の設定値を応答する
+ *
+ */
+ private float getDigitalZoomScalePreference()
+ {
+ float scale;
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ String value = preferences.getString(IPreferencePropertyAccessor.DIGITAL_ZOOM_LEVEL, IPreferencePropertyAccessor.DIGITAL_ZOOM_LEVEL_DEFAULT_VALUE);
+ try
+ {
+ Map<String, Float> range = camera.getDigitalZoomScaleRange();
+ float max = range.get(OLYCamera.DIGITAL_ZOOM_SCALE_RANGE_MAXIMUM_KEY);
+ float min = range.get(OLYCamera.DIGITAL_ZOOM_SCALE_RANGE_MINIMUM_KEY);
+
+ if (value.equals("MAX"))
+ {
+ scale = max;
+ }
+ else
+ {
+ scale = Float.parseFloat(value);
+ }
+ if (scale < min)
+ {
+ scale = min;
+ }
+ else if (scale > max)
+ {
+ scale = max;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ scale = 1.0f;
+ }
+ return (scale);
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void setCameraLiveImageView(@NonNull IImageDataReceiver target)
+ {
+ try
+ {
+ dataReceiver = target;
+ if (camera != null)
+ {
+ camera.setLiveViewListener(this);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ @Override
+ public void onUpdateLiveView(OLYCamera olyCamera, byte[] bytes, Map<String, Object> map)
+ {
+ try
+ {
+ if (dataReceiver != null)
+ {
+ dataReceiver.setImageData(bytes, map);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.support.v7.preference.PreferenceManager;
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.camera.IZoomLensControl;
+import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
+
+import jp.co.olympus.camerakit.OLYCamera;
+
+/**
+ * ズームレンズの情報を保持する
+ *
+ */
+class OlyCameraZoomLensControl implements IZoomLensControl
+{
+ private final String TAG = toString();
+ private boolean canZoom = false;
+ private float minimumLength = 0.0f;
+ private float maximumLength = 0.0f;
+ private float currentLength = 0.0f;
+
+ private final Context context;
+ private final OLYCamera camera;
+
+ OlyCameraZoomLensControl(Context context, OLYCamera camera)
+ {
+ this.context = context;
+ this.camera = camera;
+ initialize();
+ }
+
+ private void initialize()
+ {
+ if (camera != null)
+ {
+ String mountStatus = camera.getLensMountStatus();
+ //Log.v(TAG, "OlyCameraZoomLensControl() : " + mountStatus);
+ canZoom = ((mountStatus != null)&&(mountStatus.contains("electriczoom")));
+ if (mountStatus != null)
+ {
+ try
+ {
+ minimumLength = camera.getMinimumFocalLength();
+ maximumLength = camera.getMaximumFocalLength();
+ currentLength = camera.getActualFocalLength();
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean canZoom()
+ {
+ initialize();
+ return (canZoom);
+ }
+
+ @Override
+ public void updateStatus()
+ {
+ initialize();
+ }
+
+ @Override
+ public float getMaximumFocalLength()
+ {
+ return (maximumLength);
+ }
+
+ @Override
+ public float getMinimumFocalLength()
+ {
+ return (minimumLength);
+ }
+
+ @Override
+ public float getCurrentFocalLength()
+ {
+ return (currentLength);
+ }
+
+ /**
+ * ズームレンズを動作させる
+ *
+ * @param targetLength 焦点距離
+ */
+ @Override
+ public void driveZoomLens(float targetLength)
+ {
+ try
+ {
+ // 現在位置を設定する
+ initialize();
+
+ // レンズがサポートする焦点距離と、現在の焦点距離を取得する
+ float targetFocalLength = targetLength;
+
+ // 焦点距離が最大値・最小値を超えないようにする
+ if (targetFocalLength > maximumLength)
+ {
+ targetFocalLength = maximumLength;
+ }
+ if (targetFocalLength < minimumLength)
+ {
+ targetFocalLength = minimumLength;
+ }
+
+ // レンズのスーム操作
+ Log.v(TAG, "ZOOM from " + currentLength + "mm to " + targetFocalLength + "mm");
+
+ // ズーム動作中でない時には、レンズをズームさせる
+ if (!camera.isDrivingZoomLens())
+ {
+ camera.startDrivingZoomLensToFocalLength(targetFocalLength);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * ズームレンズを動作させる
+ *
+ * @param isZoomIn 寄る方向に動かす場合は true
+ */
+ @Override
+ public void driveZoomLens(boolean isZoomIn)
+ {
+ try
+ {
+ // 現在位置を設定する
+ initialize();
+ float targetFocalLength = currentLength;
+ if (isZoomIn)
+ {
+ // 寄る
+ targetFocalLength = targetFocalLength * 1.15f;
+ }
+ else
+ {
+ // 引く
+ targetFocalLength = targetFocalLength * 0.9f;
+ }
+
+ // 焦点距離が最大値・最小値を超えないようにする
+ if (targetFocalLength > maximumLength)
+ {
+ targetFocalLength = maximumLength;
+ }
+ if (targetFocalLength < minimumLength)
+ {
+ targetFocalLength = minimumLength;
+ }
+
+ // レンズのスーム操作
+ Log.v(TAG, "ZOOM from " + currentLength + "mm to " + targetFocalLength + "mm");
+
+ // ズーム動作中でない時には、レンズをズームさせる
+ if (!camera.isDrivingZoomLens())
+ {
+ camera.startDrivingZoomLensToFocalLength(targetFocalLength);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * ズームレンズの初期位置に移動させる
+ */
+ @Override
+ public void moveInitialZoomPosition()
+ {
+ initialize();
+ if (!canZoom())
+ {
+ // ズームできない場合、何もせずに応答する
+ Log.v(TAG, "moveInitialZoomPosition() : not PZ lens.");
+ return;
+ }
+
+ float scale;
+ float focalLength;
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ String value = preferences.getString(IPreferencePropertyAccessor.POWER_ZOOM_LEVEL, IPreferencePropertyAccessor.POWER_ZOOM_LEVEL_DEFAULT_VALUE);
+ try
+ {
+ scale = Float.parseFloat(value);
+ if (scale == 0.0f)
+ {
+ focalLength = minimumLength;
+ }
+ else if (scale == 1.0f)
+ {
+ focalLength = maximumLength;
+ }
+ else
+ {
+ focalLength = (maximumLength + minimumLength) / scale;
+ }
+ driveZoomLens(focalLength);
+ //Log.v(TAG, "moveInitialZoomPosition() : zoom to " + focalLength + "mm");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 現在ズーム中か確認する
+ *
+ * @return true : ズーム中 / false : ズーム中でない
+ */
+ @Override
+ public boolean isDrivingZoomLens()
+ {
+ return ((camera != null)&&(camera.isDrivingZoomLens()));
+ }
+
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper;
+
+import android.app.Activity;
+
+import net.osdn.gokigen.gr2control.camera.ICameraButtonControl;
+import net.osdn.gokigen.gr2control.camera.ICameraConnection;
+import net.osdn.gokigen.gr2control.camera.ICameraHardwareStatus;
+import net.osdn.gokigen.gr2control.camera.ICameraInformation;
+import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
+import net.osdn.gokigen.gr2control.camera.ICameraStatus;
+import net.osdn.gokigen.gr2control.camera.ICameraStatusReceiver;
+import net.osdn.gokigen.gr2control.camera.ICameraStatusWatcher;
+import net.osdn.gokigen.gr2control.camera.ICaptureControl;
+import net.osdn.gokigen.gr2control.camera.IDisplayInjector;
+import net.osdn.gokigen.gr2control.camera.IFocusingControl;
+import net.osdn.gokigen.gr2control.camera.IFocusingModeNotify;
+import net.osdn.gokigen.gr2control.camera.ILiveViewControl;
+import net.osdn.gokigen.gr2control.camera.IZoomLensControl;
+import net.osdn.gokigen.gr2control.camera.olympus.IOlympusInterfaceProvider;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.connection.OlyCameraConnection;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.playback.OlyCameraPlaybackControl;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
+import net.osdn.gokigen.gr2control.camera.olympus.wrapper.property.OlyCameraPropertyProxy;
+import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
+import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
+import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
+
+/**
+ *
+ *
+ */
+public class OlympusInterfaceProvider implements IOlympusInterfaceProvider, IDisplayInjector
+{
+ private final OlyCameraWrapper wrapper;
+ private final OlyCameraConnection connection;
+ private final OlyCameraPropertyProxy propertyProxy;
+ private final OlyCameraHardwareStatus hardwareStatus;
+ private final OLYCameraPropertyListenerImpl propertyListener;
+ private final OlyCameraZoomLensControl zoomLensControl;
+ private final OlyCameraPlaybackControl playbackControl;
+ private final OlyCameraStatusWrapper statusWrapper;
+ private OlyCameraFocusControl focusControl = null;
+ private OlyCameraCaptureControl captureControl = null;
+
+
+ public OlympusInterfaceProvider(Activity context, ICameraStatusReceiver provider)
+ {
+ this.wrapper = new OlyCameraWrapper(context);
+ this.connection = new OlyCameraConnection(context, this.wrapper.getOLYCamera(), provider);
+ this.propertyProxy = new OlyCameraPropertyProxy(this.wrapper.getOLYCamera());
+ this.hardwareStatus = new OlyCameraHardwareStatus(this.wrapper.getOLYCamera());
+ this.propertyListener = new OLYCameraPropertyListenerImpl(this.wrapper.getOLYCamera());
+ this.zoomLensControl = new OlyCameraZoomLensControl(context, this.wrapper.getOLYCamera());
+ this.playbackControl = new OlyCameraPlaybackControl(this.wrapper.getOLYCamera());
+ this.statusWrapper = new OlyCameraStatusWrapper(this.wrapper.getOLYCamera());
+ }
+
+ @Override
+ public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
+ {
+ focusControl = new OlyCameraFocusControl(wrapper, frameDisplayer, indicator);
+ captureControl = new OlyCameraCaptureControl (wrapper, frameDisplayer, indicator);
+ propertyListener.setFocusingControl(focusingModeNotify);
+ }
+
+ @Override
+ public ICameraConnection getOlyCameraConnection()
+ {
+ return (connection);
+ }
+
+ @Override
+ public ICameraHardwareStatus getHardwareStatus()
+ {
+ return (hardwareStatus);
+ }
+
+ @Override
+ public IOlyCameraPropertyProvider getCameraPropertyProvider()
+ {
+ return (propertyProxy);
+ }
+
+ @Override
+ public ICameraStatus getCameraStatusListHolder()
+ {
+ return (statusWrapper);
+ }
+
+ @Override
+ public ICameraStatusWatcher getCameraStatusWatcher()
+ {
+ return (statusWrapper);
+ }
+
+ @Override
+ public IPlaybackControl getPlaybackControl()
+ {
+ return (playbackControl);
+ }
+
+ @Override
+ public ICameraRunMode getCameraRunMode()
+ {
+ return (wrapper);
+ }
+
+ @Override
+ public IZoomLensControl getZoomLensControl()
+ {
+ return (zoomLensControl);
+ }
+
+ @Override
+ public ILiveViewControl getLiveViewControl()
+ {
+ return (wrapper);
+ }
+
+ @Override
+ public ILiveViewListener getLiveViewListener()
+ {
+ return (wrapper);
+ }
+
+ @Override
+ public IFocusingControl getFocusingControl()
+ {
+ return (focusControl);
+ }
+
+ @Override
+ public ICaptureControl getCaptureControl() {
+ return (captureControl);
+ }
+
+ @Override
+ public ICameraButtonControl getButtonControl()
+ {
+ return (null);
+ }
+
+ @Override
+ public ICameraInformation getCameraInformation()
+ {
+ return (propertyListener);
+ }
+
+ @Override
+ public IDisplayInjector getDisplayInjector()
+ {
+ return (this);
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper.connection;
+
+import android.content.Context;
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.R;
+import net.osdn.gokigen.gr2control.camera.ICameraStatusReceiver;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraKitException;
+
+/**
+ * Olympusカメラとの接続処理
+ *
+ */
+class CameraConnectSequence implements Runnable
+{
+ private final String TAG = this.toString();
+ private final Context context;
+ private final OLYCamera camera;
+ private final ICameraStatusReceiver cameraStatusReceiver;
+
+ /**
+ * コンストラクタ
+ */
+ CameraConnectSequence(Context context, OLYCamera camera, ICameraStatusReceiver statusReceiver)
+ {
+ Log.v(TAG, "CameraConnectSequence");
+ this.context = context;
+ this.camera =camera;
+ this.cameraStatusReceiver = statusReceiver;
+ }
+
+ /**
+ * カメラとの接続実処理
+ *
+ */
+ @Override
+ public void run()
+ {
+ String statusMessage = context.getString(R.string.connect_start);
+ try
+ {
+ statusMessage = context.getString(R.string.connect_check_wifi);
+ cameraStatusReceiver.onStatusNotify(statusMessage);
+ camera.connect(OLYCamera.ConnectionType.WiFi);
+
+ // ライブビューの自動スタート設定の場合、自動スタートをやめる
+ if (camera.isAutoStartLiveView())
+ {
+ camera.setAutoStartLiveView(false);
+ }
+
+ // 一度カメラの動作モードを確認する
+ OLYCamera.RunMode runMode = camera.getRunMode();
+ if (runMode == OLYCamera.RunMode.Unknown)
+ {
+ // UNKNOWNモードは動作しない、メッセージを作って応答する
+ statusMessage = context.getString(R.string.fatal_cannot_use_camera);
+ cameraStatusReceiver.onCameraOccursException(statusMessage, new IllegalStateException(context.getString(R.string.camera_reset_required)));
+ Log.w(TAG, "DETECT : OLYCamera.RunMode.Unknown");
+ }
+ if (runMode != OLYCamera.RunMode.Recording)
+ {
+ // Recordingモードでない場合は切り替える
+ statusMessage = context.getString(R.string.connect_change_run_mode);
+ cameraStatusReceiver.onStatusNotify(statusMessage);
+ camera.changeRunMode(OLYCamera.RunMode.Recording);
+ }
+ }
+ catch (OLYCameraKitException e)
+ {
+ cameraStatusReceiver.onCameraOccursException(statusMessage, e);
+ e.printStackTrace();
+ return;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return;
+ }
+ Log.v(TAG, "CameraConnectSequence:: connected.");
+
+ // カメラとの接続確立を通知する
+ cameraStatusReceiver.onStatusNotify(context.getString(R.string.connect_connected));
+ cameraStatusReceiver.onCameraConnected();
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper.connection;
+
+import android.util.Log;
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraKitException;
+
+/**
+ * Olympusカメラとの切断処理
+ *
+ */
+class CameraDisconnectSequence implements Runnable
+{
+ private final String TAG = this.toString();
+
+ private final OLYCamera camera;
+ private final boolean powerOff;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ CameraDisconnectSequence(OLYCamera camera, boolean isOff)
+ {
+ this.camera = camera;
+ this.powerOff = isOff;
+ }
+
+ @Override
+ public void run()
+ {
+ // カメラをPowerOffして接続を切る
+ try
+ {
+ camera.disconnectWithPowerOff(powerOff);
+ }
+ catch (OLYCameraKitException e)
+ {
+ // エラー情報をログに出力する
+ Log.w(TAG, "To disconnect from the camera is failed. : " + e.getLocalizedMessage());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper.connection;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.ConnectivityManager;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.provider.Settings;
+import android.support.v7.app.AlertDialog;
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.R;
+import net.osdn.gokigen.gr2control.camera.ICameraConnection;
+import net.osdn.gokigen.gr2control.camera.ICameraStatusReceiver;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraConnectionListener;
+import jp.co.olympus.camerakit.OLYCameraKitException;
+
+
+/**
+ * カメラの接続・切断処理クラス
+ *
+ */
+public class OlyCameraConnection implements ICameraConnection, OLYCameraConnectionListener
+{
+ private final String TAG = toString();
+ private final Activity context;
+ private final OLYCamera camera;
+ private final Executor cameraExecutor = Executors.newFixedThreadPool(1);
+ private final BroadcastReceiver connectionReceiver;
+ private final ICameraStatusReceiver statusReceiver;
+
+ //private boolean isWatchingWifiStatus = false;
+ private CameraConnectionStatus connectionStatus = CameraConnectionStatus.UNKNOWN;
+
+ //private ConnectivityManager connectivityManager;
+ //private ConnectivityManager.NetworkCallback networkCallback = null;
+
+ // Handler for dealing with network connection timeouts.
+ // private Handler networkConnectionTimeoutHandler;
+
+ // Message to notify the network request timout handler that too much time has passed.
+ //private static final int MESSAGE_CONNECTIVITY_TIMEOUT = 1;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ public OlyCameraConnection(final Activity context, OLYCamera camera, ICameraStatusReceiver statusReceiver)
+ {
+ Log.v(TAG, "OlyCameraConnection()");
+ this.context = context;
+ this.camera = camera;
+ this.camera.setConnectionListener(this);
+/*
+ ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+ Handler networkConnectionTimeoutHandler = new Handler()
+ {
+ @Override
+ public void handleMessage(Message msg)
+ {
+ switch (msg.what)
+ {
+ case MESSAGE_CONNECTIVITY_TIMEOUT:
+ Log.d(TAG, "Network connection timeout");
+ alertConnectingFailed(context.getString(R.string.network_connection_timeout));
+ connectionStatus = CameraConnectionStatus.DISCONNECTED;
+ break;
+ }
+ }
+ };
+*/
+ this.statusReceiver = statusReceiver;
+ connectionReceiver = new BroadcastReceiver()
+ {
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+ onReceiveBroadcastOfConnection(context, intent);
+ }
+ };
+
+ }
+
+ /**
+ * Wifiが使える状態だったら、カメラと接続して動作するよ
+ *
+ */
+ private void onReceiveBroadcastOfConnection(Context context, Intent intent)
+ {
+ statusReceiver.onStatusNotify(context.getString(R.string.connect_check_wifi));
+ Log.v(TAG,context.getString(R.string.connect_check_wifi));
+
+ String action = intent.getAction();
+ try
+ {
+ if ((action != null)&&(action.equals(ConnectivityManager.CONNECTIVITY_ACTION)))
+ {
+ Log.v(TAG, "onReceiveBroadcastOfConnection() : CONNECTIVITY_ACTION");
+
+ WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+ if (wifiManager != null) {
+ WifiInfo info = wifiManager.getConnectionInfo();
+ if (wifiManager.isWifiEnabled() && info != null) {
+ if (info.getNetworkId() != -1) {
+ Log.v(TAG, "Network ID is -1, there is no currently connected network.");
+ }
+ // 自動接続が指示されていた場合は、カメラとの接続処理を行う
+ connectToCamera();
+ } else {
+ if (info == null) {
+ Log.v(TAG, "NETWORK INFO IS NULL.");
+ } else {
+ Log.v(TAG, "isWifiEnabled : " + wifiManager.isWifiEnabled() + " NetworkId : " + info.getNetworkId());
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Log.w(TAG, "onReceiveBroadcastOfConnection() EXCEPTION" + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Wifi接続状態の監視
+ * (接続の実処理は onReceiveBroadcastOfConnection() で実施)
+ */
+ @Override
+ public void startWatchWifiStatus(Context context)
+ {
+ Log.v(TAG, "startWatchWifiStatus()");
+ statusReceiver.onStatusNotify("prepare");
+
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
+ filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
+ context.registerReceiver(connectionReceiver, filter);
+ }
+
+ /**
+ * Wifi接続状態の監視終了
+ */
+ @Override
+ public void stopWatchWifiStatus(Context context)
+ {
+ Log.v(TAG, "stopWatchWifiStatus()");
+ context.unregisterReceiver(connectionReceiver);
+ disconnect(false);
+ }
+
+ /**
+ * カメラとの接続を解除する
+ *
+ * @param powerOff 真ならカメラの電源オフを伴う
+ */
+ @Override
+ public void disconnect(final boolean powerOff)
+ {
+ Log.v(TAG, "disconnect()");
+ disconnectFromCamera(powerOff);
+ connectionStatus = CameraConnectionStatus.DISCONNECTED;
+ statusReceiver.onCameraDisconnected();
+ }
+
+ /**
+ * カメラとの再接続を指示する
+ */
+ @Override
+ public void connect() {
+ connectToCamera();
+ }
+
+ @Override
+ public CameraConnectionStatus getConnectionStatus()
+ {
+ return (connectionStatus);
+ }
+
+ /**
+ * カメラの接続状態を強制更新する
+ *
+ */
+ @Override
+ public void forceUpdateConnectionStatus(CameraConnectionStatus status)
+ {
+ connectionStatus = status;
+ }
+
+
+ /**
+ * カメラの通信状態変化を監視するためのインターフェース
+ *
+ * @param camera 例外が発生した OLYCamera
+ * @param e カメラクラスの例外
+ */
+ @Override
+ public void onDisconnectedByError(OLYCamera camera, OLYCameraKitException e)
+ {
+ Log.v(TAG, "onDisconnectedByError()");
+ connectionStatus = CameraConnectionStatus.DISCONNECTED;
+
+ // カメラが切れた時に通知する
+ statusReceiver.onCameraDisconnected();
+ }
+
+ /**
+ * カメラとの切断処理
+ */
+ private void disconnectFromCamera(final boolean powerOff)
+ {
+ Log.v(TAG, "disconnectFromCamera()");
+ try
+ {
+ cameraExecutor.execute(new CameraDisconnectSequence(camera, powerOff));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * カメラとの接続処理
+ */
+ private void connectToCamera()
+ {
+ Log.v(TAG, "connectToCamera()");
+ connectionStatus = CameraConnectionStatus.CONNECTING;
+ try
+ {
+ cameraExecutor.execute(new CameraConnectSequence(context, camera, statusReceiver));
+ }
+ catch (Exception e)
+ {
+ Log.v(TAG, "connectToCamera() EXCEPTION : " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 接続リトライのダイアログを出す
+ *
+ * @param message 表示用のメッセージ
+ */
+ @Override
+ public void alertConnectingFailed(String message)
+ {
+ final AlertDialog.Builder builder = new AlertDialog.Builder(context)
+ .setTitle(context.getString(R.string.dialog_title_connect_failed))
+ .setMessage(message)
+ .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ connect();
+ }
+ })
+ .setNeutralButton(R.string.dialog_title_button_network_settings, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ try
+ {
+ // Wifi 設定画面を表示する
+ context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+ }
+ catch (android.content.ActivityNotFoundException ex)
+ {
+ // Activity が存在しなかった...設定画面が起動できなかった
+ Log.v(TAG, "android.content.ActivityNotFoundException...");
+
+ // この場合は、再試行と等価な動きとする
+ connect();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ context.runOnUiThread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ builder.show();
+ }
+ });
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper.playback;
+
+import android.graphics.BitmapFactory;
+import android.support.annotation.NonNull;
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.camera.ICameraFileInfo;
+import net.osdn.gokigen.gr2control.camera.playback.CameraFileInfo;
+import net.osdn.gokigen.gr2control.camera.playback.IContentInfoCallback;
+import net.osdn.gokigen.gr2control.camera.playback.IDownloadContentCallback;
+import net.osdn.gokigen.gr2control.camera.playback.IDownloadContentListCallback;
+import net.osdn.gokigen.gr2control.camera.playback.IDownloadThumbnailImageCallback;
+import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
+import net.osdn.gokigen.gr2control.camera.playback.ProgressEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraFileInfo;
+
+public class OlyCameraPlaybackControl implements IPlaybackControl
+{
+ private final String TAG = toString();
+ private final OLYCamera camera;
+ private List<OLYCamera> list;
+
+ public OlyCameraPlaybackControl(@NonNull OLYCamera camera)
+ {
+ this.camera = camera;
+ }
+
+ @Override
+ public String getRawFileSuffix()
+ {
+ return (".ORF");
+ }
+
+ @Override
+ public void downloadContentList(@NonNull final IDownloadContentListCallback callback)
+ {
+ try
+ {
+ camera.downloadContentList(new OLYCamera.DownloadContentListCallback() {
+ @Override
+ public void onCompleted(List<OLYCameraFileInfo> list)
+ {
+ List<ICameraFileInfo> list2 = new ArrayList<>();
+ for (OLYCameraFileInfo fileInfo : list)
+ {
+ CameraFileInfo cameraFileInfo = new CameraFileInfo(fileInfo.getDirectoryPath(), fileInfo.getFilename());
+ cameraFileInfo.setDate(fileInfo.getDatetime());
+ list2.add(cameraFileInfo);
+ }
+ callback.onCompleted(list2);
+ }
+
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ callback.onErrorOccurred(e);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ callback.onErrorOccurred(e);
+ }
+ }
+
+ @Override
+ public void getContentInfo(@NonNull String path, @NonNull IContentInfoCallback callback)
+ {
+ try
+ {
+ // ここは使っていないから何もしない
+ Log.v(TAG, "getContentInfo() : " + path);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ callback.onErrorOccurred(new NullPointerException());
+ }
+
+ @Override
+ public void updateCameraFileInfo(ICameraFileInfo info)
+ {
+ try
+ {
+ Log.v(TAG, "updateCameraFileInfo() : " + info.getFilename());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void downloadContentScreennail(@NonNull String path, @NonNull final IDownloadThumbnailImageCallback callback)
+ {
+ try
+ {
+ camera.downloadContentScreennail(path, new OLYCamera.DownloadImageCallback() {
+ @Override
+ public void onProgress(OLYCamera.ProgressEvent progressEvent)
+ {
+ // なにもしない
+ }
+
+ @Override
+ public void onCompleted(byte[] bytes, Map<String, Object> map)
+ {
+ try
+ {
+ callback.onCompleted(BitmapFactory.decodeByteArray(bytes, 0, bytes.length), map);
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ callback.onErrorOccurred(new NullPointerException());
+ }
+ }
+
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ callback.onErrorOccurred(e);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ callback.onErrorOccurred(e);
+ }
+ }
+
+ @Override
+ public void downloadContentThumbnail(@NonNull String path, @NonNull final IDownloadThumbnailImageCallback callback)
+ {
+ try
+ {
+ camera.downloadContentThumbnail(path, new OLYCamera.DownloadImageCallback() {
+ @Override
+ public void onProgress(OLYCamera.ProgressEvent progressEvent)
+ {
+ // なにもしない
+ }
+
+ @Override
+ public void onCompleted(byte[] bytes, Map<String, Object> map)
+ {
+ try
+ {
+ callback.onCompleted(BitmapFactory.decodeByteArray(bytes, 0, bytes.length), map);
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ callback.onErrorOccurred(new NullPointerException());
+ }
+ }
+
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ callback.onErrorOccurred(e);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ callback.onErrorOccurred(e);
+ }
+ }
+
+ @Override
+ public void downloadContent(@NonNull String path, boolean isSmallSize, @NonNull final IDownloadContentCallback callback)
+ {
+ try
+ {
+ camera.downloadLargeContent(path, new OLYCamera.DownloadLargeContentCallback() {
+ @Override
+ public void onProgress(byte[] bytes, OLYCamera.ProgressEvent progressEvent)
+ {
+ try
+ {
+ callback.onProgress(bytes, bytes.length, new ProgressEvent(progressEvent.getProgress(), null));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onCompleted()
+ {
+ try
+ {
+ callback.onCompleted();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onErrorOccurred(Exception e)
+ {
+ try
+ {
+ callback.onErrorOccurred(e);
+ }
+ catch (Exception ee)
+ {
+ ee.printStackTrace();
+ }
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ callback.onErrorOccurred(e);
+ }
+ }
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper.property;
+
+import jp.co.olympus.camerakit.OLYCamera;
+
+/**
+ * カメラプロパティに関する雑多な処理...
+ *
+ */
+public class CameraPropertyUtilities
+{
+ /**
+ * toLiveViewSize() : スクリーンサイズの文字列から、OLYCamera.LiveViewSize型へ変換する
+ *
+ * @param quality スクリーンサイズ文字列
+ * @return OLYCamera.LiveViewSize型
+ */
+ public static OLYCamera.LiveViewSize toLiveViewSizeType(String quality)
+ {
+ if (quality == null)
+ {
+ return OLYCamera.LiveViewSize.QVGA;
+ }
+ if (quality.equalsIgnoreCase("QVGA"))
+ {
+ return OLYCamera.LiveViewSize.QVGA;
+ }
+ else if (quality.equalsIgnoreCase("VGA"))
+ {
+ return OLYCamera.LiveViewSize.VGA;
+ } else if (quality.equalsIgnoreCase("SVGA"))
+ {
+ return OLYCamera.LiveViewSize.SVGA;
+ } else if (quality.equalsIgnoreCase("XGA"))
+ {
+ return OLYCamera.LiveViewSize.XGA;
+ } else if (quality.equalsIgnoreCase("QUAD_VGA"))
+ {
+ return OLYCamera.LiveViewSize.QUAD_VGA;
+ }
+ return OLYCamera.LiveViewSize.QVGA;
+ }
+
+ public static String getPropertyValue(String value)
+ {
+ if (value == null)
+ {
+ return ("");
+ }
+ String[] keyValue = OLYCamera.decodeCameraPropertyValue(value);
+ return (keyValue[1]);
+ }
+ }
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper.property;
+
+/**
+ * 使用するカメラプロパティのキー一覧
+ *
+ *
+ */
+public interface IOlyCameraProperty
+{
+ String TAKE_MODE = "TAKEMODE";
+ String SOUND_VOLUME_LEVEL = "SOUND_VOLUME_LEVEL";
+ String RAW = "RAW";
+
+ String FOCUS_STILL = "FOCUS_STILL";
+ String AE_LOCK_STATE = "AE_LOCK_STATE";
+
+ String AE = "AE";
+ String AE_PINPOINT = "<AE/AE_PINPOINT>";
+
+ String STILL_MF = "<FOCUS_STILL/FOCUS_MF>";
+ String STILL_AF = "<FOCUS_STILL/FOCUS_SAF>";
+
+ //String TAKE_MODE_MOVIE = "<TAKEMODE/movie>";
+ //String DRIVE_MODE_SINGLE = "<TAKE_DRIVE/DRIVE_NORMAL>";
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper.property;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public interface IOlyCameraPropertyProvider
+{
+ // 現在利用可能なカメラプロパティ名のリスト
+ Set<String> getCameraPropertyNames();
+
+ // カメラプロパティに設定されている値を取得 : 戻りは "<WB/WB_AUTO>" な感じ
+ String getCameraPropertyValue(String name);
+
+ // カメラプロパティに設定されている値を一括取得
+ Map<String, String> getCameraPropertyValues(Set<String> names);
+
+ // カメラプロパティの名称
+ String getCameraPropertyTitle(String name);
+
+ // 設定可能なカメラプロパティ値のリストを取得する
+ List<String> getCameraPropertyValueList(String name);
+
+ // カメラプロパティの表示値
+ String getCameraPropertyValueTitle(String propertyValue);
+
+ // カメラプロパティに値を設定
+ void setCameraPropertyValue (String name, String value);
+
+ // カメラプロパティに値を一括設定
+ void setCameraPropertyValues(Map<String, String> values);
+
+ // カメラプロパティに値を設定できるかを検査
+ boolean canSetCameraProperty(String name);
+}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.olympus.wrapper.property;
+
+import android.util.Log;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import jp.co.olympus.camerakit.OLYCamera;
+
+/**
+ * カメラプロパティをやり取りするクラス (Wrapperクラス)
+ */
+public class OlyCameraPropertyProxy implements IOlyCameraPropertyProvider
+{
+ private final String TAG = toString();
+ private final OLYCamera camera;
+
+ /**
+ * コンストラクタ
+ *
+ * @param camera OLYCameraクラス
+ */
+ public OlyCameraPropertyProxy(OLYCamera camera)
+ {
+ this.camera = camera;
+ }
+
+ /**
+ * フォーカス状態を知る(MF or AF)
+ * @return true : MF / false : AF
+ */
+ boolean isManualFocus()
+ {
+ boolean isManualFocus = false;
+ try
+ {
+ String value = camera.getCameraPropertyValue(IOlyCameraProperty.FOCUS_STILL);
+ Log.v(TAG, "OlyCameraPropertyProxy::isManualFocus() " + value);
+ isManualFocus = !(value.contains("AF"));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (isManualFocus);
+ }
+
+ /**
+ * AE ロック状態を知る
+ *
+ * @return true : AE Lock / false : AE Unlock
+ */
+ boolean isExposureLocked()
+ {
+ boolean isExposureLocked =false;
+ try
+ {
+ String value = camera.getCameraPropertyValue(IOlyCameraProperty.AE_LOCK_STATE);
+ Log.v(TAG, "OlyCameraPropertyProxy::isExposureLocked() " + value);
+ isExposureLocked = !(value.contains("UNLOCK"));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (isExposureLocked);
+ }
+
+ @Override
+ public Set<String> getCameraPropertyNames()
+ {
+ try
+ {
+ return (camera.getCameraPropertyNames());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public String getCameraPropertyValue(String name)
+ {
+ try
+ {
+ return (camera.getCameraPropertyValue(name));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public Map<String, String> getCameraPropertyValues(Set<String> names)
+ {
+ try
+ {
+ return (camera.getCameraPropertyValues(names));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public String getCameraPropertyTitle(String name)
+ {
+ try
+ {
+ return (camera.getCameraPropertyTitle(name));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public List<String> getCameraPropertyValueList(String name)
+ {
+ try
+ {
+ return (camera.getCameraPropertyValueList(name));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public String getCameraPropertyValueTitle(String propertyValue)
+ {
+ try
+ {
+ return (camera.getCameraPropertyValueTitle(propertyValue));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (null);
+ }
+
+ @Override
+ public void setCameraPropertyValue(String name, String value)
+ {
+ try
+ {
+ camera.setCameraPropertyValue(name, value);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void setCameraPropertyValues(Map<String, String> values)
+ {
+ try
+ {
+ camera.setCameraPropertyValues(values);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean canSetCameraProperty(String name)
+ {
+ try
+ {
+ return (camera.canSetCameraProperty(name));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (false);
+ }
+}
import java.util.Date;
import java.util.Locale;
-public class CameraFileInfo implements ICameraFileInfo
+public class CameraFileInfo implements ICameraFileInfo, ICameraFileInfoSetter
{
private final String path;
private final String name;
private String aspectRatio;
private String cameraModel;
private String latlng;
+ private long fileSize;
public CameraFileInfo(@NonNull String path, @NonNull String name)
{
}
@Override
- public void updateValues(String dateTime, String av, String tv, String sv, String xv, int orientation, String aspectRatio, String model, String latLng, boolean captured) {
+ public void updateValues(String dateTime, String av, String tv, String sv, String xv, int orientation, String aspectRatio, String model, String latLng, boolean captured)
+ {
this.av = av;
this.tv = tv;
this.sv = sv;
e.printStackTrace();
}
}
+
+ @Override
+ public void setDate(Date datetime)
+ {
+ this.dateTime = datetime;
+ }
+
}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.playback;
+
+import java.util.Date;
+
+public interface ICameraFileInfoSetter
+{
+ void setDate(Date datetime);
+}
*/
public interface IPlaybackControl
{
+ String getRawFileSuffix();
void downloadContentList(@NonNull IDownloadContentListCallback callback);
void getContentInfo(@NonNull String path, @NonNull IContentInfoCallback callback);
void updateCameraFileInfo(ICameraFileInfo info);
import net.osdn.gokigen.gr2control.camera.ICameraButtonControl;
import net.osdn.gokigen.gr2control.camera.ICameraConnection;
+import net.osdn.gokigen.gr2control.camera.ICameraHardwareStatus;
import net.osdn.gokigen.gr2control.camera.ICameraInformation;
import net.osdn.gokigen.gr2control.camera.ICameraStatus;
import net.osdn.gokigen.gr2control.camera.ICameraStatusWatcher;
import net.osdn.gokigen.gr2control.camera.IDisplayInjector;
import net.osdn.gokigen.gr2control.camera.IFocusingControl;
import net.osdn.gokigen.gr2control.camera.ILiveViewControl;
+import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
import net.osdn.gokigen.gr2control.camera.IZoomLensControl;
import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
ICameraButtonControl getButtonControl();
ICameraStatusWatcher getCameraStatusWatcher();
IPlaybackControl getPlaybackControl();
+
+ ICameraHardwareStatus getHardwareStatus();
+ ICameraRunMode getCameraRunMode();
}
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.ricohgr2.operation;
+
+import net.osdn.gokigen.gr2control.camera.ICameraHardwareStatus;
+
+import java.util.Map;
+
+public class RicohGr2HardwareStatus implements ICameraHardwareStatus
+{
+ @Override
+ public boolean isAvailableHardwareStatus()
+ {
+ return (false);
+ }
+
+ @Override
+ public String getLensMountStatus()
+ {
+ return (null);
+ }
+
+ @Override
+ public String getMediaMountStatus()
+ {
+ return (null);
+ }
+
+ @Override
+ public float getMinimumFocalLength()
+ {
+ return (0);
+ }
+
+ @Override
+ public float getMaximumFocalLength()
+ {
+ return (0);
+ }
+
+ @Override
+ public float getActualFocalLength()
+ {
+ return (0);
+ }
+
+ @Override
+ public Map<String, Object> inquireHardwareInformation()
+ {
+ return (null);
+ }
+}
import net.osdn.gokigen.gr2control.camera.ICameraButtonControl;
import net.osdn.gokigen.gr2control.camera.ICameraConnection;
+import net.osdn.gokigen.gr2control.camera.ICameraHardwareStatus;
import net.osdn.gokigen.gr2control.camera.ICameraInformation;
import net.osdn.gokigen.gr2control.camera.ICameraStatus;
import net.osdn.gokigen.gr2control.camera.ICameraStatusReceiver;
import net.osdn.gokigen.gr2control.camera.IFocusingControl;
import net.osdn.gokigen.gr2control.camera.IFocusingModeNotify;
import net.osdn.gokigen.gr2control.camera.ILiveViewControl;
+import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
import net.osdn.gokigen.gr2control.camera.IZoomLensControl;
import net.osdn.gokigen.gr2control.camera.ricohgr2.IRicohGr2InterfaceProvider;
import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2CameraCaptureControl;
import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2CameraFocusControl;
import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2CameraZoomLensControl;
+import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2HardwareStatus;
import net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper.connection.RicohGr2Connection;
import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, IDisplayInjector
{
private final String TAG = toString();
- private final Activity activity;
- private final ICameraStatusReceiver provider;
+ //private final Activity activity;
+ //private final ICameraStatusReceiver provider;
private final RicohGr2Connection gr2Connection;
private final RicohGr2CameraButtonControl buttonControl;
private final RicohGr2StatusChecker statusChecker;
private final RicohGr2PlaybackControl playbackControl;
+ private final RicohGr2HardwareStatus hardwareStatus;
+ private final RicohGr2RunMode runMode;
private RicohGr2LiveViewControl liveViewControl;
private RicohGr2CameraCaptureControl captureControl;
private RicohGr2CameraZoomLensControl zoomControl;
*/
public RicohGr2InterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
{
- this.activity = context;
- this.provider = provider;
+ //this.activity = context;
+ //this.provider = provider;
gr2Connection = new RicohGr2Connection(context, provider);
liveViewControl = new RicohGr2LiveViewControl();
zoomControl = new RicohGr2CameraZoomLensControl();
buttonControl = new RicohGr2CameraButtonControl();
statusChecker = new RicohGr2StatusChecker(500);
playbackControl = new RicohGr2PlaybackControl();
+ hardwareStatus = new RicohGr2HardwareStatus();
+ runMode = new RicohGr2RunMode();
}
- /**
- *
- *
- */
public void prepare()
{
Log.v(TAG, "prepare()");
}
- /**
- *
- *
- */
@Override
public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
{
captureControl = new RicohGr2CameraCaptureControl(frameDisplayer);
}
- /**
- *
- *
- */
@Override
public ICameraConnection getRicohGr2CameraConnection()
{
return (gr2Connection);
}
- /**
- *
- *
- */
@Override
public ILiveViewControl getLiveViewControl()
{
return (liveViewControl);
}
- /**
- *
- *
- */
@Override
public ILiveViewListener getLiveViewListener()
{
{
return (playbackControl);
}
+
+ @Override
+ public ICameraHardwareStatus getHardwareStatus()
+ {
+ return (hardwareStatus);
+ }
+
+ @Override
+ public ICameraRunMode getCameraRunMode()
+ {
+ return (runMode);
+ }
}
}
@Override
+ public String getRawFileSuffix()
+ {
+ return (".DNG");
+ }
+
+ @Override
public void downloadContentList(@NonNull IDownloadContentListCallback callback)
{
List<ICameraFileInfo> fileList = new ArrayList<>();
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper;
+
+import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
+
+public class RicohGr2RunMode implements ICameraRunMode
+{
+ @Override
+ public void changeRunMode(boolean isRecording)
+ {
+ // 何もしない...
+ }
+
+ @Override
+ public boolean isRecordingMode()
+ {
+ return (true);
+ }
+}
package net.osdn.gokigen.gr2control.liveview;
import android.app.Activity;
-import android.content.Context;
import android.content.SharedPreferences;
+import android.support.annotation.NonNull;
import android.support.v7.preference.PreferenceManager;
import android.util.Log;
import android.view.MotionEvent;
import net.osdn.gokigen.gr2control.R;
import net.osdn.gokigen.gr2control.camera.ICameraConnection;
-import net.osdn.gokigen.gr2control.camera.ICameraInformation;
import net.osdn.gokigen.gr2control.camera.ICaptureControl;
import net.osdn.gokigen.gr2control.camera.IFocusingControl;
import net.osdn.gokigen.gr2control.camera.IInterfaceProvider;
import net.osdn.gokigen.gr2control.scene.ConfirmationDialog;
import net.osdn.gokigen.gr2control.scene.IChangeScene;
-
/**
*
*
private final IFavoriteSettingDialogKicker dialogKicker;
private final IZoomLensControl zoomLensControl;
- LiveViewClickTouchListener(Activity context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IInterfaceProvider interfaceProvider, IFavoriteSettingDialogKicker dialogKicker)
+ LiveViewClickTouchListener(@NonNull Activity context, @NonNull ILiveImageStatusNotify imageStatusNotify, @NonNull IStatusViewDrawer statusView, @NonNull IChangeScene changeScene, @NonNull IInterfaceProvider interfaceProvider, @NonNull IFavoriteSettingDialogKicker dialogKicker)
{
this.context = context;
this.statusNotify = imageStatusNotify;
this.changeScene = changeScene;
this.interfaceProvider = interfaceProvider;
- //ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
- //if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
- {
- this.focusingControl = interfaceProvider.getRicohGr2Infterface().getFocusingControl();
- this.captureControl = interfaceProvider.getRicohGr2Infterface().getCaptureControl();
- //this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
- //this.cameraInformation = interfaceProvider.getRicohGr2Infterface().getCameraInformation();
- this.cameraConnection = interfaceProvider.getRicohGr2Infterface().getRicohGr2CameraConnection();
- this.zoomLensControl = interfaceProvider.getRicohGr2Infterface().getZoomLensControl();
- }
-/*
- else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
- {
- this.focusingControl = interfaceProvider.getSonyInterface().getFocusingControl();
- this.captureControl = interfaceProvider.getSonyInterface().getCaptureControl();
- this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
- this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
- this.cameraConnection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
- this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
- }
- else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
- {
- this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
- this.captureControl = interfaceProvider.getOlympusInterface().getCaptureControl();
- this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
- this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
- this.cameraConnection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
- this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
- }
-*/
+ this.focusingControl = interfaceProvider.getFocusingControl();
+ this.captureControl = interfaceProvider.getCaptureControl();
+ this.cameraConnection = interfaceProvider.getCameraConnection();
+ this.zoomLensControl = interfaceProvider.getZoomLensControl();
+
this.dialogKicker = dialogKicker;
}
try
{
int id = view.getId();
- ICameraStatus statusList = interfaceProvider.getRicohGr2Infterface().getCameraStatusListHolder();
+ ICameraStatus statusList = interfaceProvider.getCameraStatusListHolder();
if (statusList == null)
{
// ステータスリストの保持クラスが取れなかった...
import net.osdn.gokigen.gr2control.R;
import net.osdn.gokigen.gr2control.camera.ICameraConnection;
import net.osdn.gokigen.gr2control.camera.ICameraInformation;
+import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
import net.osdn.gokigen.gr2control.camera.ICameraStatusWatcher;
import net.osdn.gokigen.gr2control.camera.IDisplayInjector;
import net.osdn.gokigen.gr2control.camera.IFocusingModeNotify;
import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
import net.osdn.gokigen.gr2control.scene.IChangeScene;
-
/**
* 撮影用ライブビュー画面
*
public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFocusingModeNotify, IFavoriteSettingDialogKicker, ICameraStatusUpdateNotify
{
private final String TAG = this.toString();
- private static final int COMMAND_MY_PROPERTY = 0x00000100;
private ILiveViewControl liveViewControl = null;
- private IZoomLensControl zoomLensControl = null;
+ //private IZoomLensControl zoomLensControl = null;
private IInterfaceProvider interfaceProvider = null;
private IDisplayInjector interfaceInjector = null;
//private OlympusCameraLiveViewListenerImpl liveViewListener = null;
{
Log.v(TAG, "prepare()");
- IDisplayInjector interfaceInjector;
- interfaceInjector = interfaceProvider.getRicohGr2Infterface().getDisplayInjector();
-/*
- ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
- if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
- {
- interfaceInjector = interfaceProvider.getRicohGr2Infterface().getDisplayInjector();
- }
- else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
- {
- interfaceInjector = interfaceProvider.getSonyInterface().getDisplayInjector();
- }
- else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
- {
- interfaceInjector = interfaceProvider.getOlympusInterface().getDisplayInjector();
- }
-*/
this.changeScene = sceneSelector;
this.interfaceProvider = interfaceProvider;
- this.interfaceInjector = interfaceInjector;
-
- //if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
- {
- this.liveViewControl = interfaceProvider.getRicohGr2Infterface().getLiveViewControl();
- this.zoomLensControl = interfaceProvider.getRicohGr2Infterface().getZoomLensControl();
- this.cameraInformation = interfaceProvider.getRicohGr2Infterface().getCameraInformation();
- this.statusWatcher = interfaceProvider.getRicohGr2Infterface().getCameraStatusWatcher();
- }
-/*
- else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
- {
- this.liveViewControl = interfaceProvider.getSonyInterface().getSonyLiveViewControl();
- this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
- this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
- }
- else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
- {
- this.liveViewControl = interfaceProvider.getOlympusInterface().getLiveViewControl();
- this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
- this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
- }
-*/
+ this.interfaceInjector = interfaceProvider.getDisplayInjector();
+ this.liveViewControl = interfaceProvider.getLiveViewControl();
+ //this.zoomLensControl = interfaceProvider.getZoomLensControl();
+ this.cameraInformation = interfaceProvider.getCameraInformation();
+ this.statusWatcher = interfaceProvider.getCameraStatusWatcher();
}
/**
}
}
-/*
// 撮影モードかどうかを確認して、撮影モードではなかったら撮影モードに切り替える
+ ICameraRunMode changeRunModeExecutor = interfaceProvider.getCameraRunMode();
if ((changeRunModeExecutor != null)&&(!changeRunModeExecutor.isRecordingMode()))
{
- // Runモードを切り替える。(でも切り替えると、設定がクリアされてしまう...。
+ // Runモードを切り替える。(でも切り替えると、設定がクリアされてしまう...。)
changeRunModeExecutor.changeRunMode(true);
}
+/*
// ステータスの変更を通知してもらう
camera.setCameraStatusListener(statusListener);
liveViewControl.changeLiveViewSize(preferences.getString(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY, IPreferencePropertyAccessor.LIVE_VIEW_QUALITY_DEFAULT_VALUE));
isCameraScreen = preferences.getBoolean(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW, true);
}
- ILiveViewListener lvListener = interfaceProvider.getRicohGr2Infterface().getLiveViewListener();
-/*
- ILiveViewListener lvListener;
- if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
- {
- lvListener = interfaceProvider.getRicohGr2Infterface().getLiveViewListener();
- }
- else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
+ ILiveViewListener lvListener = interfaceProvider.getLiveViewListener();
+ if (lvListener != null)
{
- lvListener = interfaceProvider.getSonyInterface().getLiveViewListener();
+ lvListener.setCameraLiveImageView(imageView);
}
- else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
- {
- interfaceProvider.getOlympusLiveViewListener().setOlympusLiveViewListener(liveViewListener);
- lvListener = liveViewListener;
- }
-*/
-
- lvListener.setCameraLiveImageView(imageView);
liveViewControl.startLiveView(isCameraScreen); // false : ライブビューのみ、 true : カメラ画面をミラー
// ステータス監視も実施する
}
if (keyId.length() > 1)
{
- ICameraButtonControl buttonControl = interfaceProvider.getRicohGr2Infterface().getButtonControl();
+ ICameraButtonControl buttonControl = interfaceProvider.getButtonControl();
if (buttonControl != null)
{
buttonControl.pushedButton(keyId);
import net.osdn.gokigen.gr2control.R;
import net.osdn.gokigen.gr2control.camera.ICameraFileInfo;
+import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
import net.osdn.gokigen.gr2control.camera.playback.IDownloadContentListCallback;
import net.osdn.gokigen.gr2control.camera.playback.IDownloadThumbnailImageCallback;
import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
private final String TAG = this.toString();
private final String MOVIE_SUFFIX = ".mov";
private final String JPEG_SUFFIX = ".jpg";
- private final String RAW_SUFFIX = ".dng";
+ private final String RAW_SUFFIX_1 = ".dng";
+ private final String RAW_SUFFIX_2 = ".orf";
+
private GridView gridView;
private boolean gridViewIsScrolling;
private IPlaybackControl playbackControl;
+ private ICameraRunMode runMode;
private List<ImageContentInfoEx> contentList;
private ExecutorService executor;
private LruCache<String, Bitmap> imageCache;
- public static ImageGridViewFragment newInstance(@NonNull IPlaybackControl playbackControl)
+ public static ImageGridViewFragment newInstance(@NonNull IPlaybackControl playbackControl, @NonNull ICameraRunMode runMode)
{
ImageGridViewFragment fragment = new ImageGridViewFragment();
- fragment.setPlaybackControl(playbackControl);
+ fragment.setControllers(playbackControl, runMode);
return (fragment);
}
- private void setPlaybackControl(IPlaybackControl playbackControl)
+ private void setControllers(IPlaybackControl playbackControl, ICameraRunMode runMode)
{
this.playbackControl = playbackControl;
+ this.runMode = runMode;
}
@Override
}
}
}
+
try
{
refresh();
public void onPause()
{
Log.v(TAG, "onPause() Start");
+ if (!runMode.isRecordingMode())
+ {
+ // Threadで呼んではダメみたいだ...
+ runMode.changeRunMode(true);
+ }
+
if (!executor.isShutdown())
{
executor.shutdownNow();
private void refresh()
{
+ try
+ {
+ if (runMode.isRecordingMode())
+ {
+ runMode.changeRunMode(false);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
+/*
+ if (runMode.isRecordingMode())
+ {
+ runMode.changeRunMode(false);
+ }
+*/
refreshImpl();
}
});
{
contentItems.add(new ImageContentInfoEx(item, false));
}
- else if (path.toLowerCase().endsWith(RAW_SUFFIX))
+ else if (path.toLowerCase().endsWith(RAW_SUFFIX_1))
{
rawItems.put(path, new ImageContentInfoEx(item, true));
}
+ else if (path.toLowerCase().endsWith(RAW_SUFFIX_2))
+ {
+ rawItems.put(path, new ImageContentInfoEx(item, true));
+ }
+
}
for (ImageContentInfoEx item : contentItems)
String path = item.getFileInfo().getFilename().toLowerCase(Locale.getDefault());
if (path.toLowerCase().endsWith(JPEG_SUFFIX))
{
- String target = path.replace(JPEG_SUFFIX, RAW_SUFFIX);
- ImageContentInfoEx raw = rawItems.get(target);
- if (raw != null)
+ String target1 = path.replace(JPEG_SUFFIX, RAW_SUFFIX_1);
+ ImageContentInfoEx raw1 = rawItems.get(target1);
+ if (raw1 != null)
{
// RAW は、JPEGファイルがあった場合にのみリストする
item.setHasRaw(true);
- Log.v(TAG, "DETECT RAW FILE: " + target);
+ Log.v(TAG, "DETECT RAW FILE: " + target1);
+ }
+ String target2 = path.replace(JPEG_SUFFIX, RAW_SUFFIX_2);
+ ImageContentInfoEx raw2 = rawItems.get(target2);
+ if (raw2 != null)
+ {
+ // RAW は、JPEGファイルがあった場合にのみリストする
+ item.setHasRaw(true);
+ Log.v(TAG, "DETECT RAW FILE: " + target2);
}
}
}
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- ImagePagerViewFragment fragment = ImagePagerViewFragment.newInstance(playbackControl, contentList, position);
+ ImagePagerViewFragment fragment = ImagePagerViewFragment.newInstance(playbackControl, runMode, contentList, position);
FragmentActivity activity = getActivity();
if (activity != null)
{
import net.osdn.gokigen.gr2control.R;
import net.osdn.gokigen.gr2control.camera.ICameraFileInfo;
+import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
import net.osdn.gokigen.gr2control.camera.playback.IDownloadThumbnailImageCallback;
import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
{
private final String TAG = this.toString();
private static final String JPEG_SUFFIX = ".JPG";
- private static final String RAW_SUFFIX = ".DNG";
+
private IPlaybackControl playbackControl;
+ private ICameraRunMode runMode;
private List<ImageContentInfoEx> contentList = null;
private int contentIndex = 0;
private LruCache<String, Bitmap> imageCache =null;
- public static ImagePagerViewFragment newInstance(@NonNull IPlaybackControl playbackControl, @NonNull List<ImageContentInfoEx> contentList, int contentIndex)
+ public static ImagePagerViewFragment newInstance(@NonNull IPlaybackControl playbackControl, @NonNull ICameraRunMode runMode, @NonNull List<ImageContentInfoEx> contentList, int contentIndex)
{
ImagePagerViewFragment fragment = new ImagePagerViewFragment();
- fragment.setInterface(playbackControl);
+ fragment.setInterface(playbackControl, runMode);
fragment.setContentList(contentList, contentIndex);
return (fragment);
}
- private void setInterface(@NonNull IPlaybackControl playbackControl)
+ private void setInterface(@NonNull IPlaybackControl playbackControl, @NonNull ICameraRunMode runMode)
{
this.playbackControl = playbackControl;
+ this.runMode = runMode;
}
else if (item.getItemId() == R.id.action_download_raw)
{
doDownload = true;
- specialSuffix = RAW_SUFFIX;
+ specialSuffix = playbackControl.getRawFileSuffix();
}
if (getInformation)
bar.show();
}
}
- viewPager.setCurrentItem(contentIndex);
+
+ if (runMode.isRecordingMode())
+ {
+ // Threadで呼んではダメみたいだ...
+ runMode.changeRunMode(false);
+ }
+
+ viewPager.setCurrentItem(contentIndex);
}
@Override
bar.hide();
}
}
- }
+
+ if (!runMode.isRecordingMode())
+ {
+ // Threadで呼んではダメみたいだ...
+ runMode.changeRunMode(true);
+ }
+ }
private class ImagePagerAdapter extends PagerAdapter
{
public void run() {
MyContentDownloader contentDownloader = new MyContentDownloader(activity, playbackControl);
ICameraFileInfo fileInfo = (contentList.get(contentIndex)).getFileInfo();
- contentDownloader.startDownload(fileInfo, (filename.endsWith(RAW_SUFFIX)) ? RAW_SUFFIX : null, isSmallSize);
+ contentDownloader.startDownload(fileInfo, (filename.endsWith(playbackControl.getRawFileSuffix())) ? playbackControl.getRawFileSuffix() : null, isSmallSize);
}
});
thread.start();
private final String TAG = toString();
private final Activity activity;
private final IPlaybackControl playbackControl;
- private static final String RAW_SUFFIX = ".DNG";
+ private static final String RAW_SUFFIX_1 = ".DNG";
+ private static final String RAW_SUFFIX_2 = ".ORF";
private static final String MOVIE_SUFFIX = ".MOV";
private static final String JPEG_SUFFIX = ".JPG";
private ProgressDialog downloadDialog = null;
{
targetFileName = targetFileName.replace(JPEG_SUFFIX, replaceJpegSuffix);
}
- if (targetFileName.toUpperCase().contains(RAW_SUFFIX))
+ if (targetFileName.toUpperCase().contains(RAW_SUFFIX_1))
{
mimeType = "image/x-adobe-dng";
}
+ else if (targetFileName.toUpperCase().contains(RAW_SUFFIX_2))
+ {
+ mimeType = "image/image/x-olympus-orf";
+ }
else if (targetFileName.toUpperCase().contains(MOVIE_SUFFIX))
{
mimeType = "video/mp4";
outputStream.close();
outputStream = null;
}
- if (!targetFileName.toUpperCase().endsWith(RAW_SUFFIX))
+ if ((!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_1))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_2)))
{
// ギャラリーに受信したファイルを登録する
long now = System.currentTimeMillis();
}
try
{
- ICameraConnection connection = getCameraConnection(interfaceProvider.getCammeraConnectionMethod());
+ interfaceProvider.resetCameraConnectionMethod();
+ ICameraConnection connection = interfaceProvider.getCameraConnection();
if (connection != null)
{
ICameraConnection.CameraConnectionStatus status = connection.getConnectionStatus();
Log.v(TAG, "changeScenceToImageList()");
try
{
- ImageGridViewFragment fragment = ImageGridViewFragment.newInstance(interfaceProvider.getRicohGr2Infterface().getPlaybackControl());
+ ImageGridViewFragment fragment = ImageGridViewFragment.newInstance(interfaceProvider.getPlaybackControl(), interfaceProvider.getCameraRunMode());
FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment1, fragment);
// backstackに追加
private ICameraConnection getCameraConnection(ICameraConnection.CameraConnectionMethod method)
{
Log.v(TAG, "method : " + method);
- return (interfaceProvider.getRicohGr2Infterface().getRicohGr2CameraConnection());
+ return (interfaceProvider.getCameraConnection());
}
}
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM4,12c0,-4.42 3.58,-8 8,-8 1.85,0 3.55,0.63 4.9,1.69L5.69,16.9C4.63,15.55 4,13.85 4,12zM12,20c-1.85,0 -3.55,-0.63 -4.9,-1.69L18.31,7.1C19.37,8.45 20,10.15 20,12c0,4.42 -3.58,8 -8,8z"/>
+</vector>
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
+</vector>
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/>
+</vector>
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M14,2L6,2c-1.1,0 -1.99,0.9 -1.99,2L4,20c0,1.1 0.89,2 1.99,2L18,22c1.1,0 2,-0.9 2,-2L20,8l-6,-6zM12,18c-2.05,0 -3.81,-1.24 -4.58,-3h1.71c0.63,0.9 1.68,1.5 2.87,1.5 1.93,0 3.5,-1.57 3.5,-3.5S13.93,9.5 12,9.5c-1.35,0 -2.52,0.78 -3.1,1.9l1.6,1.6h-4L6.5,9l1.3,1.3C8.69,8.92 10.23,8 12,8c2.76,0 5,2.24 5,5s-2.24,5 -5,5z"/>
+</vector>
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
+</vector>
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:pathData="M19,4L5,4c-1.11,0 -2,0.9 -2,2v12c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.89,-2 -2,-2zM19,18L5,18L5,8h14v10z"
+ android:fillColor="#010101"/>
+</vector>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="26dp"
+ android:layout_height="wrap_content"
+ android:textStyle="normal"
+ android:textSize="6pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="id"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="80dp"
+ android:layout_height="wrap_content"
+ android:textSize="4pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="info"
+ />
+
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textStyle="normal"
+ android:textSize="9pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="title"
+ />
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <TextView
+ android:layout_width="0px"
+ android:layout_height="0px"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="5pt"
+ android:tag="id"
+ />
+ <Button xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:tag="button"
+ android:text="@string/save_props"
+ />
+ <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="88dp"
+ android:layout_height="wrap_content"
+ android:hint="@string/hint_save_props"
+ android:textSize="8pt"
+ android:inputType="text"
+ android:tag="title"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="4pt"
+ android:tag="info"
+ />
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+android:layout_height="match_parent"
+android:layout_width="match_parent"
+android:orientation="vertical"
+ >
+<android.support.v4.app.FragmentTabHost
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/tabHost01"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+</android.support.v4.app.FragmentTabHost>
+
+<android.support.v4.view.ViewPager
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"/>
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true">
+
+ <LinearLayout
+ android:id="@+id/propertyInformationPanelLayout"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="14dp"
+ android:background="@color/background_translucent_dark" >
+
+ <TextView
+ android:id="@+id/propertyInformationMessageTextView"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:gravity="start"
+ android:clickable="true"
+ android:focusable="true"
+ android:text="@string/blank"
+ android:textColor="@color/background_dark"
+ android:textSize="14sp" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/propertyConfigPanelLayout"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="24dp"
+ android:background="@color/background_translucent_dark" >
+
+ <ImageView
+ android:id="@+id/propertySettings_save"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:layout_gravity="end"
+ android:visibility="invisible"
+ android:clickable="true"
+ android:focusable="true"
+ android:scaleType="center"
+ android:contentDescription="@string/configuration"
+ android:src="@drawable/ic_save_black_24dp" />
+
+ <ImageView
+ android:id="@+id/propertySettings_refresh"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:layout_gravity="end"
+ android:visibility="invisible"
+ android:clickable="true"
+ android:focusable="true"
+ android:scaleType="center"
+ android:contentDescription="@string/configuration"
+ android:src="@drawable/ic_refresh_black_24dp" />
+
+ <ImageView
+ android:id="@+id/propertySettings_restore"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:layout_gravity="end"
+ android:visibility="visible"
+ android:clickable="true"
+ android:focusable="true"
+ android:scaleType="center"
+ android:contentDescription="@string/restore"
+ android:src="@drawable/ic_restore_page_black_24dp" />
+
+ </LinearLayout>
+
+ <ListView android:id="@+id/CameraPropertyListView"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ </ListView>
+
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="vertical"
+ >
+ <ListView
+ android:id="@id/android:list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scrollbars="vertical"
+ android:scrollbarFadeDuration="1000000"/>
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <ImageView
+ android:id="@+id/ObjectStyleIcons"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:scaleType="fitCenter"
+ android:tag="icon"
+ android:src="@drawable/ic_photo_camera_black_24dp"
+ android:contentDescription="@string/icon"
+ android:layout_gravity="center_vertical"
+ android:maxHeight="18dp"
+ android:minWidth="18dp">
+ </ImageView>
+ <TextView
+ android:textSize="9pt"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/ObjectDataTitle"
+ android:tag="title"
+ android:maxWidth="130dp"
+ android:minWidth="130dp"
+ android:layout_gravity="start">
+ </TextView>
+ <TextView
+ android:textSize="6pt"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/ObjectDataDetail"
+ android:tag="value"
+ android:linksClickable="true"
+ android:maxWidth="100dp"
+ android:minWidth="100dp"
+ android:layout_gravity="center_vertical">
+ </TextView>
+ <TextView
+ android:textSize="4pt"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/ObjectDataValue"
+ android:tag="name"
+ android:autoLink="all"
+ android:linksClickable="true"
+ android:layout_gravity="center_vertical">
+ </TextView>
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="26dp"
+ android:layout_height="wrap_content"
+ android:textStyle="normal"
+ android:textSize="6pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="id"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="80dp"
+ android:layout_height="wrap_content"
+ android:textSize="4pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="info"
+ />
+
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textStyle="normal"
+ android:textSize="9pt"
+ android:clickable="false"
+ android:focusable="false"
+ android:tag="title"
+ />
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <TextView
+ android:layout_width="0px"
+ android:layout_height="0px"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="5pt"
+ android:tag="id"
+ />
+ <Button xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:tag="button"
+ android:text="@string/save_props"
+ />
+ <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="88dp"
+ android:layout_height="wrap_content"
+ android:hint="@string/hint_save_props"
+ android:textSize="8pt"
+ android:inputType="text"
+ android:tag="title"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="4pt"
+ android:tag="info"
+ />
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+android:layout_height="match_parent"
+android:layout_width="match_parent"
+android:orientation="vertical"
+ >
+<android.support.v4.app.FragmentTabHost
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/tabHost01"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+</android.support.v4.app.FragmentTabHost>
+
+<android.support.v4.view.ViewPager
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"/>
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true">
+
+ <LinearLayout
+ android:id="@+id/propertyInformationPanelLayout"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="14dp"
+ android:background="@color/background_translucent_dark" >
+
+ <TextView
+ android:id="@+id/propertyInformationMessageTextView"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:gravity="start"
+ android:clickable="true"
+ android:focusable="true"
+ android:text="@string/blank"
+ android:textColor="@color/background_dark"
+ android:textSize="14sp" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/propertyConfigPanelLayout"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="24dp"
+ android:background="@color/background_translucent_dark" >
+
+ <ImageView
+ android:id="@+id/propertySettings_save"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:layout_gravity="end"
+ android:visibility="invisible"
+ android:clickable="true"
+ android:focusable="true"
+ android:scaleType="center"
+ android:contentDescription="@string/configuration"
+ android:src="@drawable/ic_save_black_24dp" />
+
+ <ImageView
+ android:id="@+id/propertySettings_refresh"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:layout_gravity="end"
+ android:visibility="invisible"
+ android:clickable="true"
+ android:focusable="true"
+ android:scaleType="center"
+ android:contentDescription="@string/configuration"
+ android:src="@drawable/ic_refresh_black_24dp" />
+
+ <ImageView
+ android:id="@+id/propertySettings_restore"
+ android:layout_width="0dp"
+ android:layout_height="fill_parent"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:layout_gravity="end"
+ android:visibility="visible"
+ android:clickable="true"
+ android:focusable="true"
+ android:scaleType="center"
+ android:contentDescription="@string/restore"
+ android:src="@drawable/ic_restore_page_black_24dp" />
+
+ </LinearLayout>
+
+ <ListView android:id="@+id/CameraPropertyListView"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ </ListView>
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="vertical"
+ >
+ <ListView
+ android:id="@id/android:list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scrollbars="vertical"
+ android:scrollbarFadeDuration="1000000"/>
+</LinearLayout>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <ImageView
+ android:id="@+id/ObjectStyleIcons"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:scaleType="fitCenter"
+ android:tag="icon"
+ android:src="@drawable/ic_photo_camera_black_24dp"
+ android:contentDescription="@string/icon"
+ android:layout_gravity="center_vertical"
+ android:maxHeight="18dp"
+ android:minWidth="18dp">
+ </ImageView>
+ <TextView
+ android:textSize="9pt"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/ObjectDataTitle"
+ android:tag="title"
+ android:maxWidth="130dp"
+ android:minWidth="130dp"
+ android:layout_gravity="start">
+ </TextView>
+ <TextView
+ android:textSize="6pt"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/ObjectDataDetail"
+ android:tag="value"
+ android:linksClickable="true"
+ android:maxWidth="100dp"
+ android:minWidth="100dp"
+ android:layout_gravity="center_vertical">
+ </TextView>
+ <TextView
+ android:textSize="4pt"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/ObjectDataValue"
+ android:tag="name"
+ android:autoLink="all"
+ android:linksClickable="true"
+ android:layout_gravity="center_vertical">
+ </TextView>
+</LinearLayout>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
+ <color name="background_dark">#555555</color>
+ <color name="background_translucent_white">#88FFFFFF</color>
+ <color name="background_translucent_dark">#AA555555</color>
</resources>
<resources>
<string-array name="connection_method">
<item>Ricoh GR II</item>
+ <item>OPC(Olympus Air)</item>
</string-array>
<string-array name="connection_method_value">
<item >RICOH_GR2</item>
+ <item>OPC</item>
</string-array>
<string-array name="gr2_display_mode">
<color name="colorAccent">#FF4081</color>
<color name="background_dark">#555555</color>
<color name="background_translucent_white">#88FFFFFF</color>
+ <color name="background_translucent_dark">#AA555555</color>
</resources>
<string name="app_name2">AirA01a</string>
<string name="blank"> </string>
+ <string name="configuration">Settings</string>
+ <string name="restore">Restore</string>
+ <string name="icon">icon</string>
+
+
<string name="dialog_title_confirmation">Confirmation</string>
<string name="dialog_positive_execute">OK</string>
<string name="dialog_negative_cancel">Cancel</string>
<string name="dialog_title_button_retry">Retry</string>
<string name="dialog_title_button_network_settings">WiFi Settings</string>
+ <string name="dialog_title_loading_properties">Loading Camera Properties</string>
+ <string name="dialog_message_loading_properties">Please wait…</string>
+
<string name="finish_refresh">Finished Refresh</string>
+ <string name="connect_start">start</string>
<string name="connect_check_wifi">check WIFI</string>
-
+ <string name="connect_change_run_mode">changeRunMode</string>
+ <string name="fatal_cannot_use_camera">The CameraKit SDK can not work because the running mode of camera is UNKNOWN. So please long press the power button of camera more than 8 seconds. (This is the camera reset operation.) After that turn on the camera power again.</string>
+ <string name="camera_reset_required">The camera reset operation is required.</string>
<string name="camera_not_found">Not Found…</string>
<string name="connect_connected">connected</string>
+ <string name="network_connection_timeout">Connection time out</string>
<string name="pref_cat_application_control">App. Control</string>
<string name="pref_exit_power_off">Exit Application(and Camera OFF)</string>
<string name="pref_connection_method">Connection Method</string>
+ <string name="save_props">Save</string>
+ <string name="hint_save_props">Label</string>
+ <string name="saved_my_props">Saved Property : </string>
+ <string name="auto_save_props">(Auto Save)</string>
+ <string name="title_tab_title_load">Load</string>
+ <string name="title_tab_title_save">Save</string>
+ <string name="title_my_settings">Favorite Camera Properties</string>
+
+ <string name="dialog_start_save_property_message">Please Wait</string>
+ <string name="dialog_start_save_property_title">Storing Properties…</string>
+ <string name="dialog_start_load_property_message">Please Wait</string>
+ <string name="dialog_start_load_property_title">Setting Properties…</string>
+ <string name="restored_my_props">Restored Property : </string>
+ <string name="dialog_message_restore_camera_property">Restore Camera Property</string>
+
+
<string name="pref_gr2_display_mode">Display Mode</string>
<string name="pref_gr2_display_camera_view">Mirror Camera Screen</string>
<string name="pref_gr2_display_camera_view_summary">Use same camera screen.</string>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
+ <item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
</style>
</resources>