package net.osdn.gokigen.gr2control.liveview;
-import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
+import android.graphics.Color;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Vibrator;
-import android.support.annotation.NonNull;
-import android.support.v4.app.Fragment;
-import android.support.v4.content.res.ResourcesCompat;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.preference.PreferenceManager;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+import androidx.core.content.res.ResourcesCompat;
+import androidx.core.graphics.drawable.DrawableCompat;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.PreferenceManager;
+
import android.util.Log;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
-import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import net.osdn.gokigen.gr2control.R;
+import net.osdn.gokigen.gr2control.camera.ICameraButtonControl;
import net.osdn.gokigen.gr2control.camera.ICameraConnection;
import net.osdn.gokigen.gr2control.camera.ICameraInformation;
import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
+import net.osdn.gokigen.gr2control.camera.ICameraRunModeCallback;
+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.IFocusingModeNotify;
import net.osdn.gokigen.gr2control.camera.IInterfaceProvider;
import net.osdn.gokigen.gr2control.camera.ILiveViewControl;
+import net.osdn.gokigen.gr2control.camera.IZoomLensControl;
+import net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops.LoadSaveCameraProperties;
+import net.osdn.gokigen.gr2control.camera.olympus.myolycameraprops.LoadSaveMyCameraPropertyDialog;
import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
import net.osdn.gokigen.gr2control.scene.IChangeScene;
* 撮影用ライブビュー画面
*
*/
-public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFocusingModeNotify, IFavoriteSettingDialogKicker, ICameraStatusUpdateNotify
+public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFocusingModeNotify, IFavoriteSettingDialogKicker, ICameraStatusUpdateNotify, LiveViewKeyPanelClickListener.KeyPanelFeedback, ICameraRunModeCallback
{
private final String TAG = this.toString();
private ILiveViewControl liveViewControl = null;
- //private IZoomLensControl zoomLensControl = null;
+ private IZoomLensControl zoomLensControl = null;
private IInterfaceProvider interfaceProvider = null;
private IDisplayInjector interfaceInjector = null;
//private OlympusCameraLiveViewListenerImpl liveViewListener = null;
private LiveViewClickTouchListener onClickTouchListener = null;
private LiveViewControlPanelClickListener onPanelClickListener = null;
private LiveViewKeyPanelClickListener onKeyPanelClickListener = null;
+ private LiveViewFujiXKeyPanelClickListener fujiXOnKeyPanelClickListener = null;
private TextView statusArea = null;
private TextView focalLengthArea = null;
private CameraLiveImageView imageView = null;
private ImageView manualFocus = null;
- private ImageButton showGrid = null;
+ private ImageView showGrid = null;
private ImageView connectStatus = null;
private Button changeLiveViewScale = null;
*
*/
@Override
- public void onAttach(Context context)
+ public void onAttach(@NonNull Context context)
{
super.onAttach(context);
Log.v(TAG, "onAttach()");
{
Log.v(TAG, "interfaceInjector is NULL...");
}
- Activity activity = this.getActivity();
+ FragmentActivity activity = this.getActivity();
Vibrator vibrator = (activity != null) ? (Vibrator) activity.getSystemService(VIBRATOR_SERVICE) : null;
if ((onClickTouchListener == null)&&(activity != null))
{
imageView.setOnClickListener(onClickTouchListener);
imageView.setOnTouchListener(onClickTouchListener);
+ // キーイベントを拾うことにする
+ view.setOnKeyListener(onClickTouchListener);
+ view.setFocusableInTouchMode(true);
+
setOnClickListener(view, R.id.hideControlPanelTextView);
setOnClickListener(view, R.id.showControlPanelTextView);
setOnClickListener(view, R.id.showKeyPanelImageView);
setOnClickListener(view, R.id.show_images_button);
setOnClickListener(view, R.id.camera_power_off_button);
setOnClickListener(view, R.id.show_preference_button);
+ setOnClickListener(view, R.id.show_hide_grid_button);
+ setOnClickListener(view, R.id.zoom_in_button);
+ setOnClickListener(view, R.id.zoom_out_button);
+ setOnClickListener(view, R.id.specialButtonImageView);
+ setOnClickListener(view, R.id.fuji_x_hideKeyPanelTextView);
if (onPanelClickListener == null)
{
setPanelClickListener(view, R.id.shutterSpeedTextView);
setPanelClickListener(view, R.id.apertureValueTextView);
setPanelClickListener(view, R.id.exposureCompensationTextView);
- setPanelClickListener(view, R.id.aeModeTextView);
- setPanelClickListener(view, R.id.whiteBalanceImageView);
+ setPanelClickListener(view, R.id.aeModeImageView);
+ setPanelClickListener(view, R.id.whiteBalanceTextView);
+ setPanelClickListener(view, R.id.isoSensitivityTextView);
setPanelClickListener(view, R.id.setEffectImageView);
if (onKeyPanelClickListener == null)
{
- onKeyPanelClickListener = new LiveViewKeyPanelClickListener(interfaceProvider, vibrator);
+ onKeyPanelClickListener = new LiveViewKeyPanelClickListener(interfaceProvider, this, vibrator);
}
setKeyPanelClickListener(view, R.id.button_front_left);
setKeyPanelClickListener(view, R.id.button_front_right);
setKeyPanelClickListener(view, R.id.button_plus);
setKeyPanelClickListener(view, R.id.button_minus);
setKeyPanelClickListener(view, R.id.button_playback);
+ setKeyPanelClickListener(view, R.id.button_acclock);
+ setKeyPanelClickListener(view, R.id.button_lcd_onoff);
+ setKeyPanelClickListener(view, R.id.button_highlight);
- /*
- 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.btn_zoomin).setOnClickListener(onClickTouchListener);
- view.findViewById(R.id.btn_zoomout).setOnClickListener(onClickTouchListener);
-
- manualFocus = view.findViewById(R.id.focusing_button);
- changeLiveViewScale = view.findViewById(R.id.live_view_scale_button);
-
- ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
-
- if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
- {
- view.findViewById(R.id.show_favorite_settings_button).setOnClickListener(onClickTouchListener);
- }
- else
- {
- // お気に入りボタン(とMFボタン)は、SONYモード, RICOH GR2モードのときには表示しない
- final View favoriteButton = view.findViewById(R.id.show_favorite_settings_button);
- final View propertyButton = view.findViewById(R.id.camera_property_settings_button);
- if ((favoriteButton != null)&&(manualFocus != null))
- {
- runOnUiThread(new Runnable()
- {
- @Override
- public void run()
- {
- favoriteButton.setVisibility(View.INVISIBLE);
- if (manualFocus != null)
- {
- manualFocus.setVisibility(View.INVISIBLE);
- }
- propertyButton.setVisibility(View.INVISIBLE);
- }
- });
- }
- if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
- {
- if (changeLiveViewScale != null)
- {
- changeLiveViewScale.setVisibility(View.INVISIBLE);
- }
- }
- else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
- {
- if (changeLiveViewScale != null)
- {
- changeLiveViewScale.setVisibility(View.VISIBLE);
- }
- }
- }
-
- if (manualFocus != null)
+ if (fujiXOnKeyPanelClickListener == null)
{
- manualFocus.setOnClickListener(onClickTouchListener);
+ fujiXOnKeyPanelClickListener = new LiveViewFujiXKeyPanelClickListener(getActivity(), interfaceProvider, vibrator);
}
- changedFocusingMode();
+ setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_sv_minus);
+ setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_sv_plus);
+ setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_tv_minus);
+ setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_tv_plus);
+ setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_xv_minus);
+ setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_xv_plus);
+ setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_flash);
+ setFujiXKeyPanelClickListener(view, R.id.button_fuji_x_timer);
- if (changeLiveViewScale != null)
- {
- changeLiveViewScale.setOnClickListener(onClickTouchListener);
- }
-
- showGrid = view.findViewById(R.id.show_hide_grid_button);
- showGrid.setOnClickListener(onClickTouchListener);
- updateGridIcon();
-
- updateConnectionStatus(ICameraConnection.CameraConnectionStatus.UNKNOWN);
-
- statusArea = view.findViewById(R.id.informationMessageTextView);
- focalLengthArea = view.findViewById(R.id.focal_length_with_digital_zoom_view);
-*/
connectStatus = view.findViewById(R.id.connect_disconnect_button);
if (connectStatus != null)
{
connectStatus.setOnClickListener(onClickTouchListener);
}
+
+ View keyPanel = view.findViewById(R.id.showKeyPanelImageView);
+ ICameraButtonControl buttonControl = interfaceProvider.getButtonControl();
+ if (keyPanel != null)
+ {
+ keyPanel.setVisibility((buttonControl == null) ? View.INVISIBLE : View.VISIBLE);
+ keyPanel.invalidate();
+ }
}
catch (Exception e)
{
if (button != null)
{
button.setOnClickListener(onKeyPanelClickListener);
+ button.setOnLongClickListener(onKeyPanelClickListener);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void setFujiXKeyPanelClickListener(View view, int id)
+ {
+ try
+ {
+ View button = view.findViewById(id);
+ if (button != null)
+ {
+ button.setOnClickListener(fujiXOnKeyPanelClickListener);
+ button.setOnLongClickListener(fujiXOnKeyPanelClickListener);
}
}
catch (Exception e)
this.interfaceProvider = interfaceProvider;
this.interfaceInjector = interfaceProvider.getDisplayInjector();
this.liveViewControl = interfaceProvider.getLiveViewControl();
- //this.zoomLensControl = interfaceProvider.getZoomLensControl();
+ this.zoomLensControl = interfaceProvider.getZoomLensControl();
this.cameraInformation = interfaceProvider.getCameraInformation();
this.statusWatcher = interfaceProvider.getCameraStatusWatcher();
}
{
try
{
- int id = (imageView.isShowGrid()) ? R.drawable.ic_grid_off_black_24dp : R.drawable.ic_grid_on_black_24dp;
- showGrid.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
- showGrid.invalidate();
- imageView.invalidate();
+ FragmentActivity activity = getActivity();
+ if (activity != null)
+ {
+ if (showGrid == null) {
+ showGrid = activity.findViewById(R.id.show_hide_grid_button);
+ }
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run()
+ {
+ int id = (imageView.isShowGrid()) ? R.drawable.ic_grid_off_black_24dp : R.drawable.ic_grid_on_black_24dp;
+ if (showGrid != null)
+ {
+ showGrid.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
+ showGrid.invalidate();
+ }
+ imageView.invalidate();
+ }
+ });
+ }
}
catch (Exception e)
{
}
/**
- * AF/MFの表示を更新する
+ *
*
*/
@Override
if ((changeRunModeExecutor != null)&&(!changeRunModeExecutor.isRecordingMode()))
{
// Runモードを切り替える。(でも切り替えると、設定がクリアされてしまう...。)
- changeRunModeExecutor.changeRunMode(true);
+ changeRunModeExecutor.changeRunMode(true, this);
+ Log.v(TAG, "onResume() End");
+ return;
}
+ prepareToStart();
+ Log.v(TAG, "onResume() End");
+ }
-/*
- // ステータスの変更を通知してもらう
- camera.setCameraStatusListener(statusListener);
-
- // 画面下部の表示エリアの用途を切り替える
- setupLowerDisplayArea();
-*/
- // propertyを取得
+ private void prepareToStart()
+ {
try
{
Context context = getContext();
{
e.printStackTrace();
}
- Log.v(TAG, "onResume() End");
+ }
+
+ @Override
+ public void onCompleted(boolean isRecording)
+ {
+ prepareToStart();
+ }
+
+ @Override
+ public void onErrorOccurred(boolean isRecording)
+ {
+ prepareToStart();
}
/**
@Override
public void startLiveView()
{
+ Log.v(TAG, " LiveViewFragment::startLiveView() ");
ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
if (liveViewControl == null)
{
}
liveViewControl.startLiveView(isCameraScreen); // false : ライブビューのみ、 true : カメラ画面をミラー
+ // ここでグリッドアイコンを更新する
+ updateGridIcon();
+
+ // ここでズームレンズ制御ができるか確認する
+ if ((zoomLensControl != null)&&(zoomLensControl.canZoom()))
+ {
+ //Log.v(TAG, "CAN ZOOM LENS");
+ updateZoomlensControl(true);
+ }
+ else
+ {
+ //Log.v(TAG, "NO ZOOM LENS");
+ updateZoomlensControl(false);
+ }
+
+
// ステータス監視も実施する
startWatchStatus();
}
try
{
Log.v(TAG, "showFavoriteSettingDialog()");
-/*
- LoadSaveMyCameraPropertyDialog dialog = new LoadSaveMyCameraPropertyDialog();
- dialog.setTargetFragment(this, COMMAND_MY_PROPERTY);
- dialog.setPropertyOperationsHolder(new LoadSaveCameraProperties(getActivity(), interfaceProvider.getOlympusInterface()));
- FragmentManager manager = getFragmentManager();
- if (manager != null)
- {
- dialog.show(manager, "my_dialog");
- }
-*/
+ LoadSaveMyCameraPropertyDialog dialog = LoadSaveMyCameraPropertyDialog.newInstance(new LoadSaveCameraProperties(getActivity(), interfaceProvider.getOlympusInterfaceProvider()));
+ dialog.show(getChildFragmentManager(), "favorite_dialog");
}
catch (Exception e)
{
/**
*
*
+ *
+ */
+ private void updateZoomlensControl(final boolean isVisible)
+ {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ // isVisibleがtrueなら、ズームレンズボタンを有効にする
+ FragmentActivity activity = getActivity();
+ if (activity != null)
+ {
+ try
+ {
+ View view1 = activity.findViewById(R.id.zoom_out_button);
+ if (view1 != null)
+ {
+ view1.setVisibility((isVisible) ? View.VISIBLE : View.INVISIBLE);
+ view1.invalidate();
+ }
+
+ View view2 = activity.findViewById(R.id.zoom_in_button);
+ if (view2 != null)
+ {
+ view2.setVisibility((isVisible) ? View.VISIBLE : View.INVISIBLE);
+ view2.invalidate();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ *
+ *
*/
private void startWatchStatus()
{
{
if (statusWatcher != null)
{
- statusWatcher.stoptStatusWatch();
+ statusWatcher.stopStatusWatch();
}
}
*/
private void runOnUiThread(Runnable action)
{
- Activity activity = getActivity();
+ FragmentActivity activity = getActivity();
if (activity == null)
{
return;
{
try
{
- final Activity activity = getActivity();
+ final FragmentActivity activity = getActivity();
if (activity == null)
{
return;
try
{
final String shutterSpeed = tv.replace(".", "/");
- final Activity activity = getActivity();
+ final FragmentActivity activity = getActivity();
if (activity == null)
{
return;
try
{
final String apertureValue = (av.length() > 1) ? ("F" + av) : "";
- final Activity activity = getActivity();
+ final FragmentActivity activity = getActivity();
if (activity == null)
{
return;
{
try
{
- final Activity activity = getActivity();
+ final FragmentActivity activity = getActivity();
if (activity == null)
{
return;
{
try
{
- final Activity activity = getActivity();
- if (activity == null)
+ Log.v(TAG, "updatedMeteringMode() : " + meteringMode);
+ final FragmentActivity activity = getActivity();
+ if ((activity == null)||(meteringMode == null))
{
return;
}
+
+ int iconId = R.drawable.ic_crop_free_black_24dp;
+ switch (meteringMode)
+ {
+ case ICameraStatus.AE_STATUS_MULTI:
+ case ICameraStatus.AE_STATUS_ESP:
+ iconId = R.drawable.ic_crop_free_black_24dp;
+ break;
+ case ICameraStatus.AE_STATUS_CENTER:
+ case ICameraStatus.AE_STATUS_CENTER2:
+ iconId = R.drawable.ic_center_focus_weak_black_24dp;
+ break;
+ case ICameraStatus.AE_STATUS_SPOT:
+ case ICameraStatus.AE_STATUS_PINPOINT:
+ iconId = R.drawable.ic_filter_center_focus_black_24dp;
+ break;
+ }
+ final int id = iconId;
activity.runOnUiThread(new Runnable()
{
@Override
public void run()
{
- TextView view = activity.findViewById(R.id.aeModeTextView);
+ ImageView view = activity.findViewById(R.id.aeModeImageView);
if (view != null)
{
- view.setText(meteringMode);
+ view.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
view.invalidate();
}
}
@Override
public void updatedWBMode(final String wbMode)
{
- // とりあえず何もしない... 選択肢は以下
+ // とりあえず何もしない... 選択肢は以下 (Ricohの場合...)
// auto, multiAuto, daylight, shade, cloud, tungsten, warmWhiteFluorescent, daylightFluorescent, dayWhiteFluorescent, coolWhiteFluorescent, incandescent,manual1, cte, custom
}
*
*/
@Override
- public void updateRemainBattery(int percentage)
+ public void updateRemainBattery(final int percentage)
{
try
{
- final Activity activity = getActivity();
+ final FragmentActivity activity = getActivity();
if (activity == null)
{
return;
ImageView view = activity.findViewById(R.id.currentBatteryImageView);
if (view != null)
{
- view.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
- view.invalidate();
+ Drawable target = ResourcesCompat.getDrawable(getResources(), id, null);
+ if (target != null)
+ {
+ if (percentage <= 20)
+ {
+ DrawableCompat.setTint(target, Color.RED);
+ } else if (percentage <= 40)
+ {
+ DrawableCompat.setTint(target, Color.YELLOW);
+ }
+ view.setImageDrawable(target);
+ view.invalidate();
+ }
}
}
});
e.printStackTrace();
}
}
+
+ @Override
+ public void updateFocusedStatus(final boolean focused, final boolean focusLocked)
+ {
+ final FragmentActivity activity = getActivity();
+ try
+ {
+ if (activity != null)
+ {
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ try
+ {
+ ImageView view = activity.findViewById(R.id.focusUnlockImageView);
+ if (focused) {
+ Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_center_focus_strong_black_24dp, null);
+ if (icon != null) {
+ DrawableCompat.setTint(icon, Color.GREEN);
+ view.setImageDrawable(icon);
+ }
+ } else {
+ Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_focus_free_black_24dp, null);
+ if (icon != null) {
+ int color = Color.BLACK;
+ if (focusLocked) {
+ color = Color.RED;
+ }
+ DrawableCompat.setTint(icon, color);
+ view.setImageDrawable(icon);
+ }
+ }
+ view.invalidate();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void updateIsoSensitivity(String sv)
+ {
+ Log.v(TAG, "updateIsoSensitivity : " + sv);
+ }
+
+ @Override
+ public void updateWarning(String warning)
+ {
+ Log.v(TAG, "updateWarning : " + warning);
+ }
+
+ @Override
+ public void updateStorageStatus(String status)
+ {
+ Log.v(TAG, "updateStorageStatus : " + status);
+ }
+
+ @Override
+ public void updateToggleButton(boolean isOn)
+ {
+ try
+ {
+ FragmentActivity activity = getActivity();
+ if (activity != null)
+ {
+ ImageView imageView = activity.findViewById(R.id.button_toggle_aeaf);
+ if (isOn)
+ {
+ imageView.setImageDrawable(ContextCompat.getDrawable(activity,R.drawable.ic_radio_button_checked_black_24dp));
+ }
+ else
+ {
+ imageView.setImageDrawable(ContextCompat.getDrawable(activity,R.drawable.ic_radio_button_unchecked_black_24dp));
+ }
+ imageView.invalidate();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void updateLcdOnOff(boolean isOn)
+ {
+ Log.v(TAG, "updateLcdOnOff() " + isOn);
+ }
+
+ @Override
+ public void updateAFLlever(boolean isCaf)
+ {
+ try
+ {
+ FragmentActivity activity = getActivity();
+ if (activity != null)
+ {
+ TextView textView = activity.findViewById(R.id.lever_ael_caf);
+ if (isCaf)
+ {
+ textView.setText(getString(R.string.label_c_af));
+ }
+ else
+ {
+ textView.setText(getString(R.string.label_aelock));
+ }
+ textView.invalidate();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public boolean handleKeyDown(int keyCode, KeyEvent event)
+ {
+ return (onClickTouchListener.onKey(null, keyCode, event));
+ }
}