import net.osdn.gokigen.a01d.camera.olympus.wrapper.OlympusInterfaceProvider;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ICameraStatusReceiver;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
-import net.osdn.gokigen.a01d.liveview.CameraLiveViewListenerImpl;
import net.osdn.gokigen.a01d.liveview.IStatusViewDrawer;
import net.osdn.gokigen.a01d.liveview.LiveViewFragment;
import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
* A01d ;
*
*/
-public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver, IChangeScene {
+public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver, IChangeScene
+{
private final String TAG = toString();
private IOlympusInterfaceProvider interfaceProvider = null;
private IOlympusDisplayInjector interfaceInjector = null;
package net.osdn.gokigen.a01d.camera.olympus;
+import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraHardwareStatus;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraRunMode;
ICameraRunMode getCameraRunMode();
ILiveViewControl getLiveViewControl();
IFocusingControl getFocusingControl();
+ ICaptureControl getCaptureControl();
}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.operation;
+
+/**
+ * 撮影用のインタフェース
+ *
+ */
+public interface ICaptureControl
+{
+ void doCapture(int kind);
+}
{
boolean driveAutoFocus(MotionEvent motionEvent);
void unlockAutoFocus();
+ void changeFocusingMode();
+
}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.wrapper;
+
+import android.util.Log;
+
+import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
+import net.osdn.gokigen.a01d.camera.olympus.operation.takepicture.SingleShotControl;
+import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
+import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
+
+public class OlyCameraCaptureControl implements ICaptureControl
+{
+ private final String TAG = toString();
+ private final SingleShotControl singleShotControl;
+
+ public 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();
+ }
+ }
+}
e.printStackTrace();
}
}
+
+ @Override
+ public void changeFocusingMode()
+ {
+
+ }
}
import net.osdn.gokigen.a01d.camera.olympus.IOlympusDisplayInjector;
import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ICameraStatusReceiver;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
private final OlyCameraPropertyProxy propertyProxy;
private final OlyCameraHardwareStatus hardwareStatus;
private OlyCameraFocusControl focusControl = null;
+ private OlyCameraCaptureControl captureControl = null;
public OlympusInterfaceProvider(Activity context, ICameraStatusReceiver provider)
{
public void injectOlympusDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
{
focusControl = new OlyCameraFocusControl(wrapper, frameDisplayer, indicator);
+ captureControl = new OlyCameraCaptureControl (wrapper, frameDisplayer, indicator);
}
@Override
{
return (focusControl);
}
+
+ @Override
+ public ICaptureControl getCaptureControl() {
+ return (captureControl);
+ }
}
private IGridFrameDrawer gridFrameDrawer = null;
private IPreviewImageConverter bitmapConverter = null;
private IMessageHolder messageHolder;
+ private IStoreImage storeImage = null;
public CameraLiveImageView(Context context)
{
private void initComponent(Context context)
{
+ storeImage = new StoreImage(context);
messageHolder = new ShowMessageHolder();
imageScaleType = ImageView.ScaleType.FIT_CENTER;
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
editor.apply();
}
+ /**
+ * 現在のライブビュー画像を保管する
+ *
+ *
+ */
+ @Override
+ public void takePicture()
+ {
+ if ((imageBitmap == null)||(storeImage == null))
+ {
+ // 保管する画像がなかった... 何もせずに終了する
+ //
+ return;
+ }
+ storeImage.doStore(imageBitmap);
+ }
+
public boolean isShowGrid()
{
return (showGridFeature);
package net.osdn.gokigen.a01d.liveview;
+import android.graphics.Bitmap;
+
import net.osdn.gokigen.a01d.liveview.message.IMessageDrawer;
/**
{
void toggleFocusAssist();
void toggleShowGridFrame();
+ void takePicture();
IMessageDrawer getMessageDrawer();
}
--- /dev/null
+package net.osdn.gokigen.a01d.liveview;
+
+import android.graphics.Bitmap;
+
+interface IStoreImage
+{
+ void doStore(final Bitmap target);
+}
package net.osdn.gokigen.a01d.liveview;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.support.v7.preference.PreferenceManager;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import net.osdn.gokigen.a01d.IChangeScene;
import net.osdn.gokigen.a01d.R;
+import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
+import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
/**
*
class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchListener
{
private final String TAG = toString();
+ private final Context context;
private final ILiveImageStatusNotify statusNotify;
private final IStatusViewDrawer statusViewDrawer;
private final IChangeScene changeScene;
private final IFocusingControl focusingControl;
+ private final ICaptureControl captureControl;
- LiveViewClickTouchListener(ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IFocusingControl focusingControl)
+ LiveViewClickTouchListener(Context context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IOlympusInterfaceProvider interfaceProvider)
{
+ this.context = context;
this.statusNotify = imageStatusNotify;
this.statusViewDrawer = statusView;
this.changeScene = changeScene;
- this.focusingControl = focusingControl;
+ this.focusingControl = interfaceProvider.getFocusingControl();
+ this.captureControl = interfaceProvider.getCaptureControl();
}
/**
changeScene.changeCameraConnection();
break;
+ case R.id.shutter_button:
+ // シャッターボタンが押された (撮影)
+ pushedShutterButton();
+ break;
+
+ case R.id.focusing_button:
+ // AF と MFの切り替えボタンが押された
+ focusingControl.changeFocusingMode();
+ break;
+
default:
Log.v(TAG, "onClick() : " + id);
break;
}
/**
+ * シャッターボタンが押された時の処理
+ *
+ *
+ */
+ private void pushedShutterButton()
+ {
+ Log.v(TAG, "pushedShutterButton()");
+ try
+ {
+ captureControl.doCapture(0);
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ if (preferences.getBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true))
+ {
+ // ライブビュー画像も保管する
+ statusNotify.takePicture();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
* オブジェクトをタッチする処理
*
*/
import net.osdn.gokigen.a01d.R;
import net.osdn.gokigen.a01d.camera.olympus.IOlympusDisplayInjector;
import net.osdn.gokigen.a01d.camera.olympus.IOlympusInterfaceProvider;
+import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ILiveViewControl;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
private IChangeScene changeScene = null;
- private IFocusingControl focusingControl = null;
+ //private IFocusingControl focusingControl = null;
private LiveViewClickTouchListener onClickTouchListener = null;
{
interfaceInjector.injectOlympusDisplay(imageView, imageView);
}
- if ((interfaceProvider != null) &&(focusingControl == null))
- {
- focusingControl = interfaceProvider.getFocusingControl();
- }
if (onClickTouchListener == null)
{
- onClickTouchListener = new LiveViewClickTouchListener(imageView, this, changeScene, focusingControl);
+ onClickTouchListener = new LiveViewClickTouchListener(this.getContext(), imageView, this, changeScene, interfaceProvider);
}
imageView.setOnClickListener(onClickTouchListener);
imageView.setOnTouchListener(onClickTouchListener);
view.findViewById(R.id.show_preference_button).setOnClickListener(onClickTouchListener);
view.findViewById(R.id.camera_property_settings_button).setOnClickListener(onClickTouchListener);
+ view.findViewById(R.id.shutter_button).setOnClickListener(onClickTouchListener);
+ view.findViewById(R.id.focusing_button).setOnClickListener(onClickTouchListener);
showGrid = view.findViewById(R.id.show_hide_grid_button);
showGrid.setOnClickListener(onClickTouchListener);
--- /dev/null
+package net.osdn.gokigen.a01d.liveview;
+
+import android.app.ProgressDialog;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.os.Environment;
+import android.provider.MediaStore;
+import android.util.Log;
+
+import net.osdn.gokigen.a01d.R;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Locale;
+
+/**
+ * 画像の保管クラス
+ *
+ */
+class StoreImage implements IStoreImage
+{
+ private final String TAG = toString();
+ private final Context context;
+
+ StoreImage(Context context)
+ {
+ this.context = context;
+ }
+
+ @Override
+ public void doStore(final Bitmap target)
+ {
+ // 保存処理(プログレスダイアログ(「保存中...」)を表示して処理する)
+ final ProgressDialog saveDialog = new ProgressDialog(context);
+ saveDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ saveDialog.setMessage(context.getString(R.string.data_saving));
+ saveDialog.setIndeterminate(true);
+ saveDialog.setCancelable(false);
+ saveDialog.show();
+ Thread thread = new Thread(new Runnable()
+ {
+ public void run()
+ {
+ System.gc();
+ saveImageImpl(target);
+ System.gc();
+ saveDialog.dismiss();
+ }
+ });
+ try
+ {
+ thread.start();
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ System.gc();
+ }
+ }
+
+ /**
+ * ビットマップイメージをファイルに出力する
+ *
+ * @param targetImage 出力するビットマップイメージ
+ */
+ private void saveImageImpl(Bitmap targetImage)
+ {
+ try
+ {
+ Calendar calendar = Calendar.getInstance();
+ final String directoryPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getPath() + "/" + context.getString(R.string.app_name2) + "/";
+ String filename = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(calendar.getTime()) + ".jpg";
+ String filepath = new File(directoryPath.toLowerCase(), filename).getPath();
+
+ final File directory = new File(directoryPath);
+ if (!directory.exists())
+ {
+ if (!directory.mkdirs())
+ {
+ Log.v(TAG, "MKDIR FAIL. : " + directoryPath);
+ }
+ }
+ FileOutputStream outputStream = new FileOutputStream(filepath);
+ targetImage.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
+ outputStream.flush();
+ outputStream.close();
+
+ long now = System.currentTimeMillis();
+ ContentValues values = new ContentValues();
+ ContentResolver resolver = context.getContentResolver();
+ values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
+ values.put(MediaStore.Images.Media.DATA, filepath);
+ values.put(MediaStore.Images.Media.DATE_ADDED, now);
+ values.put(MediaStore.Images.Media.DATE_TAKEN, now);
+ values.put(MediaStore.Images.Media.DATE_MODIFIED, now);
+ //values.put(MediaStore.Images.Media.WIDTH, targetImage.getWidth());
+ //values.put(MediaStore.Images.Media.HEIGHT, targetImage.getHeight());
+ resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:state_selected="true"
+ android:drawable="@drawable/btn_focusassist_pushed" />
+ <item
+ android:state_pressed="true"
+ android:drawable="@drawable/btn_focusassist_pushed" />
+ <item
+ android:drawable="@drawable/btn_focusassist" />
+
+</selector>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:state_selected="true"
+ android:drawable="@drawable/btn_mf_pushed" />
+ <item
+ android:state_pressed="true"
+ android:drawable="@drawable/btn_mf_pushed" />
+ <item
+ android:drawable="@drawable/btn_mf" />
+
+</selector>
--- /dev/null
+<vector android:autoMirrored="true" android:height="24dp"
+ android:viewportHeight="24.0" android:viewportWidth="24.0"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#FF000000" android:pathData="M9.4,10.5l4.77,-8.26C13.47,2.09 12.75,2 12,2c-2.4,0 -4.6,0.85 -6.32,2.25l3.66,6.35 0.06,-0.1zM21.54,9c-0.92,-2.92 -3.15,-5.26 -6,-6.34L11.88,9h9.66zM21.8,10h-7.49l0.29,0.5 4.76,8.25C21,16.97 22,14.61 22,12c0,-0.69 -0.07,-1.35 -0.2,-2zM8.54,12l-3.9,-6.75C3.01,7.03 2,9.39 2,12c0,0.69 0.07,1.35 0.2,2h7.49l-1.15,-2zM2.46,15c0.92,2.92 3.15,5.26 6,6.34L12.12,15L2.46,15zM13.73,15l-3.9,6.76c0.7,0.15 1.42,0.24 2.17,0.24 2.4,0 4.6,-0.85 6.32,-2.25l-3.66,-6.35 -0.93,1.6z"/>
+</vector>
android:visibility="visible" />
<view
- class="net.osdn.gokigen.a01d.liveview.CameraLiveImageView"
android:id="@+id/cameraLiveImageView"
+ class="net.osdn.gokigen.a01d.liveview.CameraLiveImageView"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="5"
android:gravity="center"
android:scaleType="fitCenter"
- android:visibility="visible"/>
+ android:visibility="visible" />
- <view
- android:id="@+id/consoleImageView2"
- class="net.osdn.gokigen.a01d.liveview.ScalableImageViewPanel"
+ <RelativeLayout
+ android:id="@+id/operationPanelLayout"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
- android:clickable="true"
- android:contentDescription="@string/favorite"
- android:gravity="center"
- android:scaleType="fitCenter"
- android:visibility="visible" />
+ android:background="@color/background_translucent_dark"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/focusing_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentBottom="true"
+ android:clickable="true"
+ android:contentDescription="@string/button"
+ android:layout_marginBottom="2pt"
+ android:gravity="center"
+ android:scaleType="fitCenter"
+ android:src="@drawable/btn_manual_focus"
+ android:visibility="visible" />
+
+ <ImageButton
+ android:id="@+id/shutter_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
+ android:clickable="true"
+ android:contentDescription="@string/button"
+ android:gravity="center"
+ android:scaleType="fitCenter"
+ android:src="@drawable/ic_camera_black_24dp"
+ android:visibility="visible" />
+
+ </RelativeLayout>
+
</LinearLayout>
<RelativeLayout
class="net.osdn.gokigen.a01d.liveview.ScalableImageViewPanel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:layout_weight="1"
android:clickable="true"
android:contentDescription="@string/favorite"
android:gravity="center"
android:scaleType="fitCenter"
android:visibility="visible" />
+ </LinearLayout>
- <view
- android:id="@+id/consoleImageView2"
- class="net.osdn.gokigen.a01d.liveview.ScalableImageViewPanel"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
+ <RelativeLayout
+ android:id="@+id/operationPanelLayout"
+ android:layout_width="fill_parent"
+ android:layout_height="24pt"
+ android:background="@color/background_translucent_dark"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/focusing_button"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
android:clickable="true"
- android:contentDescription="@string/favorite"
android:gravity="center"
android:scaleType="fitCenter"
- android:visibility="visible" />
- </LinearLayout>
+ android:contentDescription="@string/button"
+ android:src="@drawable/btn_manual_focus"
+ android:visibility="visible"
+ android:layout_marginLeft="2pt"
+ android:layout_marginStart="2pt"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ />
+
+ <ImageButton
+ android:id="@+id/shutter_button"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:clickable="true"
+ android:gravity="center"
+ android:scaleType="fitCenter"
+ android:contentDescription="@string/button"
+ android:src="@drawable/ic_camera_black_24dp"
+ android:visibility="visible"
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true" />
+
+ </RelativeLayout>
<RelativeLayout
android:id="@+id/informationPanelLayout"
<resources>
<string name="app_name">A01d</string>
+ <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="button">Button</string>
<string name="dialog_positive_execute">OK</string>
<string name="dialog_negative_cancel">Cancel</string>
<string name="pref_instruction_manual">操作説明</string>
<string name="pref_privacy_policy">プライバシーポリシー</string>
- <string name="information">ハロー!</string>
+ <string name="information">.</string>
<string name="favorite">お気に入り</string>
<string name="preferences">Preferences</string>
<string name="grid">Grid</string>
+
+ <string name="data_saving">保存中、お待ちください…</string>
+ <string name="save_image_failure">画像保存に失敗しました。</string>
+
</resources>
<resources>
<string name="app_name">A01d</string>
+ <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="button">Button</string>
<string name="dialog_positive_execute">OK</string>
<string name="dialog_negative_cancel">Cancel</string>
<string name="pref_instruction_manual">A01d Instructions</string>
<string name="pref_privacy_policy">Privacy Policy</string>
- <string name="information">Hello!</string>
+ <string name="information">.</string>
<string name="favorite">Favorite</string>
<string name="preferences">Preferences</string>
<string name="grid">Grid</string>
<string name="dialog_title_button_retry">Retry</string>
<string name="dialog_title_button_network_settings">WiFi Settings</string>
+ <string name="data_saving">Please wait…</string>
+ <string name="save_image_failure">Save image is failed.</string>
<string name="connect_start">start</string>
<string name="connect_check_wifi">check WIFI</string>