import net.osdn.gokigen.a01d.camera.IZoomLensControl;
import net.osdn.gokigen.a01d.camera.IDisplayInjector;
import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCamera;
-import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCameraApi;
import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
import java.util.List;
+++ /dev/null
-package net.osdn.gokigen.a01d.camera.panasonic.cameraproperty;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import android.widget.Toast;
-
-import net.osdn.gokigen.a01d.ConfirmationDialog;
-import net.osdn.gokigen.a01d.R;
-import net.osdn.gokigen.a01d.camera.IInterfaceProvider;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.ActionBar;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.fragment.app.FragmentActivity;
-import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.ListFragment;
-
-
-public class PanasonicCameraApiListFragment extends ListFragment implements SendRequestDialog.Callback
-{
- private final String TAG = toString();
- private ArrayAdapter<String> adapter;
- private List<String> dataItems = new ArrayList<>();
- private IInterfaceProvider interfaceProvider = null;
-
-
- /**
- * カメラプロパティをやり取りするインタフェースを生成する
- *
- */
- public static PanasonicCameraApiListFragment newInstance(@NonNull IInterfaceProvider interfaceProvider)
- {
- PanasonicCameraApiListFragment instance = new PanasonicCameraApiListFragment();
- instance.prepare(interfaceProvider);
-
- // パラメータはBundleにまとめておく
- Bundle arguments = new Bundle();
- //arguments.putString("title", title);
- //arguments.putString("message", message);
- instance.setArguments(arguments);
-
- return (instance);
- }
-
- /**
- *
- *
- */
- private void prepare(@NonNull IInterfaceProvider interfaceProvider)
- {
- Log.v(TAG, "prepare()");
- this.interfaceProvider = interfaceProvider;
- }
-
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
- {
- inflater.inflate(R.menu.api_view, menu);
- String title = getString(R.string.app_name) + " " + getString(R.string.pref_panasonic_api_list);
- try {
- AppCompatActivity activity = (AppCompatActivity) getActivity();
- if (activity != null)
- {
- ActionBar bar = activity.getSupportActionBar();
- if (bar != null)
- {
- bar.setTitle(title);
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
- if (item.getItemId() == R.id.action_refresh)
- {
- update();
- return (true);
- }
- if (item.getItemId() == R.id.action_share)
- {
- share();
- return (true);
- }
- return super.onOptionsItemSelected(item);
- }
-
- /**
- * API一覧の他アプリへ共有
- *
- */
- private void share()
- {
- if ((dataItems != null)&&(dataItems.size() > 0))
- {
- try
- {
- StringBuilder shareData = new StringBuilder();
- for (String item : dataItems)
- {
- shareData.append(item);
- shareData.append("\r\n");
- }
- String title = "; " + getString(R.string.pref_panasonic_api_list);
- Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
- sendIntent.putExtra(Intent.EXTRA_SUBJECT, title);
- sendIntent.setType("text/plain");
- sendIntent.putExtra(Intent.EXTRA_TEXT, new String(shareData));
- FragmentActivity activity = getActivity();
- if (activity != null)
- {
- // Intent発行(ACTION_SEND)
- startActivity(sendIntent);
- Log.v(TAG, "<<< SEND INTENT >>> : " + title);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * 表示データの更新
- *
- */
- private void update()
- {
- try
- {
- if (dataItems != null)
- {
- dataItems.clear();
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- Thread thread = new Thread(new Runnable()
- {
- @Override
- public void run()
- {
- Log.v(TAG, "START GET API LIST");
- dataItems = interfaceProvider.getSonyInterface().getApiCommands();
- Log.v(TAG, "FINISH GET API LIST");
- try
- {
- final FragmentActivity activity = getActivity();
- if (activity != null)
- {
- activity.runOnUiThread(new Runnable()
- {
- @Override
- public void run()
- {
- try
- {
- // 中身があったらクリアする
- if (adapter.getCount() > 0)
- {
- adapter.clear();
- }
-
- // リストの内容を更新する
- adapter.addAll(dataItems);
-
- // 最下部にカーソルを移したい
- ListView view = activity.findViewById(android.R.id.list);
- view.setSelection(dataItems.size());
-
- // 更新終了通知
- Toast.makeText(getActivity(), getString(R.string.finish_refresh), Toast.LENGTH_SHORT).show();
- }
- catch (Exception ee)
- {
- ee.printStackTrace();
- }
- }
- });
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- });
- try
- {
- // 本当は、ここでダイアログを出したい
- thread.start();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- @Override
- public void onResume()
- {
- super.onResume();
- Log.v(TAG, "onResume()");
-
- update();
- }
-
- @Override
- public void onPause()
- {
- super.onPause();
- Log.v(TAG, "onPause()");
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- Log.v(TAG, "SonyCameraApiListFragment::onCreate()");
- }
-
- @Override
- public void onActivityCreated(@Nullable Bundle savedInstanceState)
- {
- super.onActivityCreated(savedInstanceState);
- Log.v(TAG, "SonyCameraApiListFragment::onActivityCreated()");
- setHasOptionsMenu(true);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
- {
- adapter = new ArrayAdapter<>(inflater.getContext(), android.R.layout.simple_list_item_1, dataItems);
- setListAdapter(adapter);
- return (super.onCreateView(inflater, container, savedInstanceState));
- }
-
- @Override
- public void onListItemClick (ListView l, View v, int position, long id)
- {
- try
- {
- ListAdapter listAdapter = l.getAdapter();
- final String apiName = (String) listAdapter.getItem(position);
- final SendRequestDialog.Callback apiCallback = this;
- Log.v(TAG, "onListItemClick() [" + position + "] " + apiName);
- Activity activity = getActivity();
- if (activity != null)
- {
- activity.runOnUiThread(new Runnable()
- {
- @Override
- public void run()
- {
- SendRequestDialog dialog = SendRequestDialog.newInstance(interfaceProvider.getPanasonicInterface().getPanasonicCamera(), apiName, apiCallback);
- FragmentManager manager = getFragmentManager();
- String tag = "dialog";
- if (manager != null)
- {
- dialog.show(manager, tag);
- }
- }
- });
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * API のコマンドを発行する。
- *
- * ※ 注意: 引数パラメータはカンマ区切りで複数個を入力してもらう
- * key & Value 値 keyとvalueのあいだを : で区切る (key:value みたいな感じ)
- * $T Boolean値の True
- * $F Boolean値の False
- * #xx 数値(integer)
- * #xx.xx 数値(double)
- */
- @Override
- public void sendRequest(final String service, final String apiName, final String parameter, final String version)
- {
- String logValue = "sendRequest(" + service + ", " + apiName + ", [ " + parameter + "], " + version + ");";
- Log.v(TAG, logValue);
- try
- {
- Thread thread = new Thread(new Runnable()
- {
- @Override
- public void run()
- {
- try
- {
- // parameterを parseして、メッセージを送信する
- JSONArray params = parseParams(parameter);
- receivedReply(interfaceProvider.getSonyInterface().getCameraApi().callGenericSonyApiMethod(service, apiName, params, version));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- });
- thread.start();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- private JSONArray parseParams(final String parameter)
- {
- JSONArray params = new JSONArray();
- final String[] parameterItems = parameter.split(",");
- if (parameter.length() != 0)
- {
- for (int index = 0; index < parameterItems.length; index++)
- {
- String oneItem = parameterItems[index];
- if (oneItem.contains(":"))
- {
- // key & value と判断
- try
- {
- String[] keyValue = oneItem.split(":");
- try
- {
- String key = keyValue[0];
- String value = keyValue[1];
- if (value.contains("$T"))
- {
- params.put(new JSONObject().put(key, true));
- }
- else if (value.contains("$F"))
- {
- params.put(new JSONObject().put(key, false));
- }
- else if (value.contains("#"))
- {
- if (value.contains("."))
- {
- double doubleValue = Double.parseDouble(value.substring(1));
- params.put(new JSONObject().put(key, doubleValue));
- }
- else
- {
- int intValue = Integer.parseInt(value.substring(1));
- params.put(new JSONObject().put(key, intValue));
- }
- }
- else
- {
- params.put(new JSONObject().put(keyValue[0], keyValue[1]));
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- params.put(oneItem);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- params.put(oneItem);
- }
- } else {
- try
- {
- if (oneItem.contains("$T"))
- {
- params.put(true);
- }
- else if (oneItem.contains("$F"))
- {
- params.put(false);
- }
- else if (oneItem.contains("#"))
- {
- if (oneItem.contains("."))
- {
- double doubleValue = Double.parseDouble(oneItem.substring(1));
- params.put(doubleValue);
- } else {
- int intValue = Integer.parseInt(oneItem.substring(1));
- params.put(intValue);
- }
- }
- else
- {
- params.put(oneItem);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- params.put(oneItem);
- }
- }
- }
- }
- return (params);
- }
-
- @Override
- public void cancelled()
- {
- Log.v(TAG, "cancelled()");
- }
-
-
- private void receivedReply(final JSONObject reply)
- {
- try
- {
- final Activity activity = getActivity();
- if (activity != null)
- {
- activity.runOnUiThread(new Runnable()
- {
- @Override
- public void run()
- {
- try
- {
- ConfirmationDialog dialog = ConfirmationDialog.newInstance(getActivity());
- String replyString;
- try
- {
- replyString = reply.getString("result");
- }
- catch (Exception ee)
- {
- replyString = reply.getString("results");
- }
- dialog.show(android.R.drawable.ic_dialog_info, getString(R.string.dialog_title_reply), replyString);
- }
- catch (Exception e)
- {
- ConfirmationDialog dialog = ConfirmationDialog.newInstance(getActivity());
- String replyString = "";
- try
- {
- replyString = reply.toString(4);
- }
- catch (Exception ee)
- {
- ee.printStackTrace();
- }
- dialog.show(android.R.drawable.ic_dialog_alert, getString(R.string.dialog_title_reply), "RECEIVE ERROR \r\n" + replyString);
- e.printStackTrace();
- }
- }
- });
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- }
-
-}
+++ /dev/null
-package net.osdn.gokigen.a01d.camera.panasonic.cameraproperty;
-
-import android.util.Log;
-
-import net.osdn.gokigen.a01d.IChangeScene;
-
-import androidx.preference.Preference;
-
-/**
- *
- *
- */
-public class PanasonicCameraApiListViewer implements Preference.OnPreferenceClickListener
-{
- private final String TAG = toString();
- private final IChangeScene changeScene;
-
- /**
- *
- *
- */
- public PanasonicCameraApiListViewer(IChangeScene changeScene)
- {
- this.changeScene = changeScene;
- }
-
- /**
- *
- *
- */ public void prepare()
- {
- Log.v(TAG, "prepare() ");
- }
-
- /**
- *
- *
- */
- @Override
- public boolean onPreferenceClick(Preference preference)
- {
- if (!preference.hasKey())
- {
- return (false);
- }
-
- String preferenceKey = preference.getKey();
- if ((preferenceKey.contains("panasonic_api_list"))&&(changeScene != null))
- {
- try
- {
- // API Listを表示する
- changeScene.changeSceneToApiList();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (true);
- }
- return (false);
- }
-}
+++ /dev/null
-package net.osdn.gokigen.a01d.camera.panasonic.cameraproperty;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.Spinner;
-import android.widget.TextView;
-
-import net.osdn.gokigen.a01d.R;
-import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCamera;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.DialogFragment;
-
-
-/**
- *
- *
- */
-public class SendRequestDialog extends DialogFragment
-{
- private final String TAG = toString();
- private String method = "";
- private int selectedPosition = 0;
- private IPanasonicCamera camera = null;
- private SendRequestDialog.Callback callback = null;
- Dialog myDialog = null;
-
- /**
- *
- *
- */
- public static SendRequestDialog newInstance(@NonNull IPanasonicCamera camera, @NonNull String method, @Nullable SendRequestDialog.Callback callback)
- {
- SendRequestDialog instance = new SendRequestDialog();
- instance.prepare(camera, method, callback);
-
- // パラメータはBundleにまとめておく
- Bundle arguments = new Bundle();
- arguments.putString("method", method);
- //arguments.putString("message", message);
- instance.setArguments(arguments);
-
- return (instance);
- }
-
- /**
- *
- *
- */
- private void prepare(@NonNull IPanasonicCamera camera,@NonNull String method, @Nullable SendRequestDialog.Callback callback)
- {
- this.camera = camera;
- this.method = method;
- this.callback = callback;
- }
-
- /**
- *
- *
- */
- @Override
- public @NonNull Dialog onCreateDialog(Bundle savedInstanceState)
- {
- final Activity activity = getActivity();
-
- // 確認ダイアログの生成
- //final AlertDialog.Builder alertDialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.wear2_dialog_theme));
- final AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
-
- // Get the layout inflater
- LayoutInflater inflater = activity.getLayoutInflater();
- final View alertView = inflater.inflate(R.layout.request_edit_layout, null, false);
- alertDialog.setView(alertView);
-
- alertDialog.setIcon(R.drawable.ic_linked_camera_black_24dp);
- alertDialog.setTitle("API : " + method);
- final Spinner spinner = alertView.findViewById(R.id.spinner_selection_service);
- final TextView methodName = alertView.findViewById(R.id.method_name);
- final EditText parameter = alertView.findViewById(R.id.edit_parameter);
- final EditText version = alertView.findViewById(R.id.edit_version);
- try {
- methodName.setText("");
- version.setText(activity.getString(R.string.dialog_version_hint));
- ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, android.R.layout.simple_spinner_item);
- //adapter.addAll(cameraApi.getPanasonicApiServiceList());
-
- int defaultSelection;
- for (defaultSelection = (adapter.getCount() - 1); defaultSelection >= 0; defaultSelection--)
- {
- String item = adapter.getItem(defaultSelection);
- if ((item != null) && (item.equals("camera")))
- {
- break;
- }
- }
- if ((defaultSelection < 0) || (defaultSelection >= adapter.getCount()))
- {
- defaultSelection = 0;
- }
- spinner.setAdapter(adapter);
- spinner.setSelection(defaultSelection);
- spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
- {
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
- {
- Log.v(TAG, "onItemSelected : " + position + " (" + id + ")");
- selectedPosition = position;
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent)
- {
- Log.v(TAG, "onNothingSelected");
- }
- });
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- alertDialog.setCancelable(true);
-
- // ボタンを設定する(実行ボタン)
- alertDialog.setPositiveButton(activity.getString(R.string.dialog_positive_execute),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which)
- {
- try
- {
- Activity activity = getActivity();
- if (activity != null)
- {
- if (callback != null)
- {
- callback.sendRequest((String) spinner.getAdapter().getItem(selectedPosition), method, parameter.getText().toString(), version.getText().toString());
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- if (callback != null)
- {
- callback.cancelled();
- }
- }
- dialog.dismiss();
- }
- });
-
- // ボタンを設定する (キャンセルボタン)
- alertDialog.setNegativeButton(activity.getString(R.string.dialog_negative_cancel),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- if (callback != null)
- {
- callback.cancelled();
- }
- dialog.cancel();
- }
- });
-
- // 確認ダイアログを応答する
- myDialog = alertDialog.create();
- return (myDialog);
- }
-
-
- @Override
- public void onPause()
- {
- super.onPause();
- Log.v(TAG, "AlertDialog::onPause()");
- if (myDialog != null)
- {
- myDialog.cancel();
- }
- }
-
- /**
- * コールバックインタフェース
- *
- */
- public interface Callback
- {
- void sendRequest(String service, String apiName, String parameter, String version); // OKを選択したとき
- void cancelled(); // キャンセルしたとき
- }
-}
import net.osdn.gokigen.a01d.camera.IFocusingControl;
import net.osdn.gokigen.a01d.camera.panasonic.operation.takepicture.PanasonicAutoFocusControl;
-import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCameraApi;
+import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCamera;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
afControl = new PanasonicAutoFocusControl(frameDisplayer, indicator);
}
- public void setCameraApi(@NonNull IPanasonicCameraApi panasonicCameraApi)
+ public void setCamera(@NonNull IPanasonicCamera panasonicCamera)
{
- afControl.setCameraApi(panasonicCameraApi);
+ afControl.setCamera(panasonicCamera);
}
@Override
import android.graphics.RectF;
import android.util.Log;
-import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCameraApi;
+import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCamera;
+import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
public class PanasonicAutoFocusControl
{
private static final String TAG = PanasonicAutoFocusControl.class.getSimpleName();
+ private static final int TIMEOUT_MS = 3000;
private final IIndicatorControl indicator;
private final IAutoFocusFrameDisplay frameDisplayer;
- private IPanasonicCameraApi cameraApi = null;
+ private IPanasonicCamera camera = null;
/**
*
*
*
*/
- public void setCameraApi(@NonNull IPanasonicCameraApi panasonicCameraApi)
+ public void setCamera(@NonNull IPanasonicCamera panasonicCamera)
{
- this.cameraApi = panasonicCameraApi;
+ this.camera = panasonicCamera;
}
/**
public void lockAutoFocus(@NonNull final PointF point)
{
Log.v(TAG, "lockAutoFocus() : [" + point.x + ", " + point.y + "]");
- if (cameraApi == null)
+ if (camera == null)
{
Log.v(TAG, "ISonyCameraApi is null...");
return;
{
showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Running, 0.0);
- double posX = point.x * 100.0;
- double posY = point.y * 100.0;
+ int posX = (int) (Math.floor(point.x * 1000.0));
+ int posY = (int) (Math.floor(point.y * 1000.0));
Log.v(TAG, "AF (" + posX + ", " + posY + ")");
- JSONObject resultsObj = cameraApi.setTouchAFPosition(posX, posY);
- if (resultsObj == null)
+ String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + "cam.cgi?mode=camctrl&type=touch&value=" + posX + "/" + posY + "&value2=on", TIMEOUT_MS);
+
+ if (!reply.contains("ok"))
{
Log.v(TAG, "setTouchAFPosition() reply is null.");
}
+/*
if (findTouchAFPositionResult(resultsObj))
{
// AF FOCUSED
Log.v(TAG, "lockAutoFocus() : ERROR");
showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Failed, 1.0);
}
+*/
+ showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Errored, 1.0);
}
catch (Exception e)
{
public void halfPressShutter(final boolean isPressed)
{
Log.v(TAG, "halfPressShutter() : " + isPressed);
- if (cameraApi == null)
+ if (camera == null)
{
- Log.v(TAG, "ISonyCameraApi is null...");
+ Log.v(TAG, "IPanasonicCamera is null...");
return;
}
try
{
try
{
- JSONObject resultsObj = (isPressed) ? cameraApi.actHalfPressShutter() : cameraApi.cancelHalfPressShutter();
- if (resultsObj == null)
+ String status = (isPressed) ? "on" : "off";
+ String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + "cam.cgi?mode=camctrl&type=touch&value=500/500&value2=" + status, TIMEOUT_MS);
+ if (!reply.contains("ok"))
{
- Log.v(TAG, "halfPressShutter() [" + isPressed + "] reply is null.");
+ Log.v(TAG, "CENTER FOCUS (" + status + ") FAIL...");
}
else
{
public void unlockAutoFocus()
{
Log.v(TAG, "unlockAutoFocus()");
- if (cameraApi == null)
+ if (camera == null)
{
- Log.v(TAG, "ISonyCameraApi is null...");
+ Log.v(TAG, "IPanasonicCamera is null...");
return;
}
try
{
try
{
- JSONObject resultsObj = cameraApi.cancelTouchAFPosition();
- if (resultsObj == null)
+ String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + "cam.cgi?mode=camctrl&type=touch&value=500/500&value2=off", TIMEOUT_MS);
+ if (!reply.contains("ok"))
{
- Log.v(TAG, "cancelTouchAFPosition() reply is null.");
+ Log.v(TAG, "CENTER FOCUS (UNLOCK) FAIL...");
}
hideFocusFrame();
}
+++ /dev/null
-package net.osdn.gokigen.a01d.camera.panasonic.wrapper;
-
-import java.util.List;
-
-import androidx.annotation.NonNull;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-public interface IPanasonicCameraApi
-{
- /**/
- JSONObject getAvailableApiList();
- JSONObject getApplicationInfo();
-
- JSONObject getShootMode();
- JSONObject setShootMode(@NonNull String shootMode);
- JSONObject getAvailableShootMode();
- JSONObject getSupportedShootMode();
-
- JSONObject setTouchAFPosition(double Xpos, double Ypos);
- JSONObject getTouchAFPosition();
- JSONObject cancelTouchAFPosition();
-
- JSONObject actHalfPressShutter();
- JSONObject cancelHalfPressShutter();
-
- JSONObject setFocusMode(String focusMode);
- JSONObject getFocusMode();
- JSONObject getSupportedFocusMode();
- JSONObject getAvailableFocusMode();
-
- JSONObject startLiveview();
- JSONObject stopLiveview();
-
- JSONObject startRecMode();
- JSONObject actTakePicture();
- JSONObject awaitTakePicture();
-
- JSONObject startMovieRec();
- JSONObject stopMovieRec();
-
- JSONObject actZoom(@NonNull String direction, @NonNull String movement);
-
- JSONObject getEvent(@NonNull String version, boolean longPollingFlag);
-
- JSONObject setCameraFunction(@NonNull String cameraFunction);
-
- JSONObject getCameraMethodTypes();
-
- JSONObject getAvcontentMethodTypes();
-
- JSONObject getSchemeList();
- JSONObject getSourceList(String scheme);
-
- JSONObject getContentList(JSONArray params);
-
- JSONObject setStreamingContent(String uri);
-
- JSONObject startStreaming();
- JSONObject stopStreaming();
-
- List<String> getPanasonicApiServiceList();
- JSONObject callGenericSonyApiMethod(@NonNull String service, @NonNull String method, @NonNull JSONArray params, @NonNull String version);
-/**/
-}
+++ /dev/null
-package net.osdn.gokigen.a01d.camera.panasonic.wrapper;
-
-class PanasonicApiService implements IPanasonicApiService
-{
- private final String name;
- private final String actionUrl;
-
- PanasonicApiService(String name, String actionUrl)
- {
- this.name = name;
- this.actionUrl = actionUrl;
- }
-
- @Override
- public String getName()
- {
- return (name);
- }
-
- @Override
- public String getActionUrl()
- {
- return (actionUrl);
- }
-}
+++ /dev/null
-package net.osdn.gokigen.a01d.camera.panasonic.wrapper;
-
-import android.util.Log;
-
-import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import androidx.annotation.NonNull;
-
-class PanasonicCameraApi implements IPanasonicCameraApi
-{
- private static final String TAG = PanasonicCameraApi.class.getSimpleName();
- private static final boolean FULL_LOG = true;
-
- // API server device you want to send requests.
- private final IPanasonicCamera panasonicCamera;
- private int requestId;
-
-
- public static IPanasonicCameraApi newInstance(@NonNull IPanasonicCamera target)
- {
- return (new PanasonicCameraApi(target));
- }
-
- private PanasonicCameraApi(final @NonNull IPanasonicCamera target)
- {
- panasonicCamera = target;
- requestId = 1;
- }
-
- private String findActionListUrl(String service)
- {
- List<IPanasonicApiService> services = panasonicCamera.getApiServices();
- for (IPanasonicApiService apiService : services)
- {
- if (apiService.getName().equals(service))
- {
- return (apiService.getActionUrl());
- }
- }
- Log.v(TAG, "actionUrl not found. service : " + service);
- return (null);
- }
-
- private int id()
- {
- requestId++;
- if (requestId == 0)
- {
- requestId++;
- }
- return (requestId);
- }
-
- private void log(String msg)
- {
- if (FULL_LOG)
- {
- Log.d(TAG, msg);
- }
- }
-
-
- private JSONObject communicateJSON(@NonNull String service, @NonNull String method, @NonNull JSONArray params, @NonNull String version, int timeoutMs)
- {
- try
- {
- JSONObject requestJson = new JSONObject().put("method", method)
- .put("params", params)
- .put("id", id())
- .put("version", version);
- String url = findActionListUrl(service) + "/" + service;
- log("Request: " + requestJson.toString());
- String responseJson = SimpleHttpClient.httpPost(url, requestJson.toString(), timeoutMs);
- log("Response: " + responseJson);
- return (new JSONObject(responseJson));
- }
- catch (Exception e)
- {
- log("Exception : " + method + " " + version);
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getAvailableApiList()
- {
- try
- {
- return (communicateJSON("camera", "getAvailableApiList", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getApplicationInfo()
- {
- try
- {
- return (communicateJSON("camera", "getApplicationInfo", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getShootMode()
- {
- try
- {
- return (communicateJSON("camera", "getShootMode", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject setShootMode(@NonNull String shootMode)
- {
- try
- {
- return (communicateJSON("camera", "getShootMode", new JSONArray().put(shootMode), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getAvailableShootMode()
- {
- try {
- return (communicateJSON("camera", "getAvailableShootMode", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getSupportedShootMode()
- {
- try {
- return (communicateJSON("camera", "getSupportedShootMode", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject setTouchAFPosition(double Xpos, double Ypos)
- {
- try
- {
- Log.v(TAG, "setTouchAFPosition (" + Xpos + ", " + Ypos + ")");
- return (communicateJSON("camera", "setTouchAFPosition", new JSONArray().put(Xpos).put(Ypos), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getTouchAFPosition()
- {
- try
- {
- return (communicateJSON("camera", "getTouchAFPosition", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject cancelTouchAFPosition()
- {
- try
- {
- return (communicateJSON("camera", "cancelTouchAFPosition", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject actHalfPressShutter()
- {
- try
- {
- return (communicateJSON("camera", "actHalfPressShutter", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject cancelHalfPressShutter()
- {
- try
- {
- return (communicateJSON("camera", "cancelHalfPressShutter", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject setFocusMode(String focusMode)
- {
- try
- {
- Log.v(TAG, "setFocusMode (" + focusMode + ")");
- return (communicateJSON("camera", "setFocusMode", new JSONArray().put(focusMode), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getFocusMode()
- {
- try
- {
- return (communicateJSON("camera", "getFocusMode", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getSupportedFocusMode()
- {
- try
- {
- return (communicateJSON("camera", "getSupportedFocusMode", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getAvailableFocusMode()
- {
- try
- {
- return (communicateJSON("camera", "getAvailableFocusMode", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject startLiveview()
- {
- try {
- return (communicateJSON("camera", "startLiveview", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
-
- @Override
- public JSONObject stopLiveview()
- {
- try {
- return (communicateJSON("camera", "stopLiveview", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
-
- @Override
- public JSONObject startRecMode()
- {
- try {
- return (communicateJSON("camera", "startRecMode", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
-
- @Override
- public JSONObject actTakePicture()
- {
- try {
- return (communicateJSON("camera", "actTakePicture", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject awaitTakePicture()
- {
- try
- {
- return (communicateJSON("camera", "awaitTakePicture", new JSONArray(), "1.0", -1));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject startMovieRec()
- {
- try {
- return (communicateJSON("camera", "startMovieRec", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject stopMovieRec()
- {
- try {
- return (communicateJSON("camera", "stopMovieRec", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject actZoom(@NonNull String direction, @NonNull String movement)
- {
- try {
- return (communicateJSON("camera", "actZoom", new JSONArray().put(direction).put(movement), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
-
- @Override
- public JSONObject getEvent(@NonNull String version, boolean longPollingFlag)
- {
- try {
- int longPollingTimeout = (longPollingFlag) ? 20000 : 8000; // msec
- return (communicateJSON("camera", "getEvent", new JSONArray().put(longPollingFlag), version, longPollingTimeout));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
-
- @Override
- public JSONObject setCameraFunction(@NonNull String cameraFunction)
- {
- try {
- return (communicateJSON("camera", "setCameraFunction", new JSONArray().put(cameraFunction), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
-
- @Override
- public JSONObject getCameraMethodTypes()
- {
- try {
- return (communicateJSON("camera", "getCameraMethodTypes", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
-
- @Override
- public JSONObject getAvcontentMethodTypes()
- {
- try {
- return (communicateJSON("avContent", "getMethodTypes", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getSchemeList()
- {
- try {
- return (communicateJSON("avContent", "getSchemeList", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
-
- @Override
- public JSONObject getSourceList(String scheme)
- {
- try {
- JSONObject params = new JSONObject().put("scheme", scheme);
- return (communicateJSON("avContent", "getSourceList", new JSONArray().put(0, params), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
- }
-
- @Override
- public JSONObject getContentList(JSONArray params)
- {
- try {
- return (communicateJSON("avContent", "getContentList", new JSONArray().put(0, params), "1.3", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
-
- }
-
- @Override
- public JSONObject setStreamingContent(String uri)
- {
- try {
- JSONObject params = new JSONObject().put("remotePlayType", "simpleStreaming").put("uri", uri);
- return (communicateJSON("avContent", "setStreamingContent", new JSONArray().put(0, params), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
-
- }
-
- @Override
- public JSONObject startStreaming()
- {
- try {
- return (communicateJSON("avContent", "startStreaming", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
-
- }
-
- @Override
- public JSONObject stopStreaming()
- {
- try {
- return (communicateJSON("avContent", "stopStreaming", new JSONArray(), "1.0", -1));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (new JSONObject());
-
- }
-
- @Override
- public List<String> getPanasonicApiServiceList()
- {
- try
- {
- List<String> serviceList = new ArrayList<>();
- List<IPanasonicApiService> services = panasonicCamera.getApiServices();
- for (IPanasonicApiService apiService : services)
- {
- serviceList.add(apiService.getName());
- }
- return (serviceList);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return (null);
- }
-
- @Override
- public JSONObject callGenericSonyApiMethod(@NonNull String service, @NonNull String method, @NonNull JSONArray params, @NonNull String version)
- {
- return (communicateJSON(service, method, params, version, -1));
- }
-
- public static boolean isErrorReply(JSONObject replyJson)
- {
- return ((replyJson != null && replyJson.has("error")));
- }
-}
import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
private final ICameraStatusReceiver provider;
private final ICameraChangeListener listener;
private IPanasonicCamera panasonicCamera = null;
- private IPanasonicCameraApi panasonicCameraApi = null;
+ //private IPanasonicCameraApi panasonicCameraApi = null;
private ICameraEventObserver eventObserver = null;
private PanasonicLiveViewControl liveViewControl = null;
private PanasonicCameraFocusControl focusControl = null;
Log.v(TAG, " prepare : " + panasonicCamera.getFriendlyName() + " " + panasonicCamera.getModelName());
try
{
- this.panasonicCameraApi = PanasonicCameraApi.newInstance(panasonicCamera);
- eventObserver = CameraEventObserver.newInstance(context, panasonicCameraApi);
+ //this.panasonicCameraApi = PanasonicCameraApi.newInstance(panasonicCamera);
+ eventObserver = CameraEventObserver.newInstance(context, panasonicCamera);
liveViewControl = new PanasonicLiveViewControl(panasonicCamera);
- focusControl.setCameraApi(panasonicCameraApi);
+ focusControl.setCamera(panasonicCamera);
captureControl.setCamera(panasonicCamera);
zoomControl.setCamera(panasonicCamera);
}
{
Log.v(TAG, "CAMERA REPLIED ERROR : CHANGE RECMODE.");
}
+
+ // フォーカスに関しては、1点に切り替える(仮)
+ reply = SimpleHttpClient.httpGet(this.panasonicCamera.getCmdUrl() + "cam.cgi?mode=setsetting&type=afmode&value=1area", TIMEOUT_MS);
+ if (!reply.contains("ok"))
+ {
+ Log.v(TAG, "CAMERA REPLIED ERROR : CHANGE AF MODE 1area.");
+ }
}
catch (Exception e)
{
private DatagramSocket receiveSocket = null;
private boolean whileStreamReceive = false;
private int errorOccur = 0;
+ private static final int TIMEOUT_MAX = 3;
private static final int ERROR_MAX = 30;
private static final int RECEIVE_BUFFER_SIZE = 1024 * 1024 * 4;
- private static final int TIMEOUT_MS = 3000;
+ private static final int TIMEOUT_MS = 1000;
private static final int LIVEVIEW_PORT = 49152;
private final String LIVEVIEW_START_REQUEST = "cam.cgi?mode=startstream&value=49152";
private final String LIVEVIEW_STOP_REQUEST = "cam.cgi?mode=stopstream";
private void receiverThread()
{
+ int exceptionCount = 0;
byte[] buffer = new byte[RECEIVE_BUFFER_SIZE];
while (whileStreamReceive)
{
DatagramPacket receive_packet = new DatagramPacket(buffer, buffer.length);
if (receiveSocket != null)
{
+ receiveSocket.setSoTimeout(TIMEOUT_MS);
receiveSocket.receive(receive_packet);
checkReceiveImage(receive_packet);
+ exceptionCount = 0;
}
else
{
}
catch (Exception e)
{
+ exceptionCount++;
e.printStackTrace();
+ if (exceptionCount > TIMEOUT_MAX)
+ {
+ try
+ {
+ Log.v(TAG, "LV : RETRY REQUEST");
+
+ exceptionCount = 0;
+ String reply = SimpleHttpClient.httpGet(camera.getCmdUrl() + LIVEVIEW_START_REQUEST, TIMEOUT_MS);
+ if (!reply.contains("ok"))
+ {
+ Log.v(TAG, "LV : RETRY COMMAND FAIL...");
+ }
+ }
+ catch (Exception ee)
+ {
+ ee.printStackTrace();
+ }
+ }
}
}
try
{
return (liveViewListener);
}
-
}
import android.util.Log;
import net.osdn.gokigen.a01d.camera.ICameraChangeListener;
-import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCameraApi;
+import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCamera;
import org.json.JSONArray;
import org.json.JSONObject;
private boolean isEventMonitoring;
private boolean isActive;
- private final IPanasonicCameraApi remoteApi;
- private final ReplyJsonParser replyParser;
+ private final IPanasonicCamera remote;
+ // private final ReplyJsonParser replyParser;
private String eventVersion = "1.1"; // 初期値を "1.0" から "1.1" に更新
- public static ICameraEventObserver newInstance(@NonNull Context context, @NonNull IPanasonicCameraApi apiClient)
+ public static ICameraEventObserver newInstance(@NonNull Context context, @NonNull IPanasonicCamera apiClient)
{
return (new CameraEventObserver(context, apiClient));
}
- private CameraEventObserver(@NonNull Context context, @NonNull IPanasonicCameraApi apiClient)
+ private CameraEventObserver(@NonNull Context context, @NonNull IPanasonicCamera apiClient)
{
super();
- remoteApi = apiClient;
- replyParser = new ReplyJsonParser(new Handler(context.getMainLooper()));
+ remote = apiClient;
+ //replyParser = new ReplyJsonParser(new Handler(context.getMainLooper()));
isEventMonitoring = false;
isActive = false;
}
boolean longPolling = !firstCall;
try
{
+/*
// Call getEvent API.
JSONObject replyJson = remoteApi.getEvent(eventVersion, longPolling);
// parse
replyParser.parse(replyJson);
+*/
}
catch (Exception e)
{
{
try
{
- replyParser.setEventChangeListener(listener);
+ //replyParser.setEventChangeListener(listener);
}
catch (Exception e)
{
{
try
{
- replyParser.clearEventChangeListener();
+ //replyParser.clearEventChangeListener();
}
catch (Exception e)
{
@Override
public ICameraStatusHolder getCameraStatusHolder()
{
- return (replyParser);
+ return (null);
+ //return (replyParser);
}
@Override
--- /dev/null
+package net.osdn.gokigen.a01d.camera.panasonic.wrapper.eventlistener;
+
+import java.util.List;
+
+public class CameraStatusHolder implements ICameraStatusHolder
+{
+ @Override
+ public String getCameraStatus()
+ {
+ return (null);
+ }
+
+ @Override
+ public boolean getLiveviewStatus()
+ {
+ return (false);
+ }
+
+ @Override
+ public String getShootMode()
+ {
+ return (null);
+ }
+
+ @Override
+ public List<String> getAvailableShootModes()
+ {
+ return (null);
+ }
+
+ @Override
+ public int getZoomPosition()
+ {
+ return (0);
+ }
+
+ @Override
+ public String getStorageId()
+ {
+ return (null);
+ }
+}
+++ /dev/null
-package net.osdn.gokigen.a01d.camera.panasonic.wrapper.eventlistener;
-
-import android.os.Handler;
-import android.util.Log;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import androidx.annotation.NonNull;
-
-import net.osdn.gokigen.a01d.camera.ICameraChangeListener;
-
-public class ReplyJsonParser implements ICameraStatusHolder
-{
- private static final String TAG = ReplyJsonParser.class.getSimpleName();
- private String cameraStatus = null;
- private final Handler uiHandler;
- private ICameraChangeListener listener;
-
- private boolean currentLiveviewStatus;
- private String currentShootMode;
- private List<String> currentAvailableShootModes = Collections.unmodifiableList(new ArrayList<String>());
- private int currentZoomPosition;
- private String currentStorageId;
- private String currentFocusStatus;
-
- ReplyJsonParser(final @NonNull Handler uiHandler)
- {
- this.uiHandler = uiHandler;
- }
-
- void parse(@NonNull JSONObject replyJson)
- {
- // AvailableApis
- List<String> availableApis = findAvailableApiList(replyJson);
- if (!availableApis.isEmpty()) {
- fireApiListModifiedListener(availableApis);
- }
-
- // CameraStatus
- String cameraStatus = findCameraStatus(replyJson);
- Log.d(TAG, "getEvent cameraStatus: " + cameraStatus);
- if (cameraStatus != null && !cameraStatus.equals(this.cameraStatus)) {
- this.cameraStatus = cameraStatus;
- fireCameraStatusChangeListener(cameraStatus);
- }
-
- // LiveviewStatus
- Boolean liveviewStatus = findLiveviewStatus(replyJson);
- Log.d(TAG, "getEvent liveviewStatus: " + liveviewStatus);
- if (liveviewStatus != null && !liveviewStatus.equals(currentLiveviewStatus)) {
- currentLiveviewStatus = liveviewStatus;
- fireLiveviewStatusChangeListener(liveviewStatus);
- }
-
- // ShootMode
- String shootMode = findShootMode(replyJson);
- Log.d(TAG, "getEvent shootMode: " + shootMode);
- if (shootMode != null && !shootMode.equals(currentShootMode)) {
- currentShootMode = shootMode;
-
- // Available Shoot Modes
- List<String> shootModes = findAvailableShootModes(replyJson);
- currentAvailableShootModes = Collections.unmodifiableList(shootModes);
- fireShootModeChangeListener(shootMode);
- }
-
- // zoomPosition
- int zoomPosition = findZoomInformation(replyJson);
- Log.d(TAG, "getEvent zoomPosition: " + zoomPosition);
- if (zoomPosition != -1) {
- currentZoomPosition = zoomPosition;
- fireZoomInformationChangeListener(0, 0, zoomPosition, 0);
- }
-
- // storageId
- String storageId = findStorageId(replyJson);
- Log.d(TAG, "getEvent storageId:" + storageId);
- if (storageId != null && !storageId.equals(currentStorageId)) {
- currentStorageId = storageId;
- fireStorageIdChangeListener(storageId);
- }
-
- // focusStatus (v1.1)
- String focusStatus = findFocusStatus(replyJson);
- Log.d(TAG, "getEvent focusStatus:" + focusStatus);
- if (focusStatus != null && !focusStatus.equals(currentFocusStatus)) {
- currentFocusStatus = focusStatus;
- fireFocusStatusChangeListener(focusStatus);
- }
- }
-
- void setEventChangeListener(ICameraChangeListener listener)
- {
- this.listener = listener;
- }
-
- void clearEventChangeListener()
- {
- listener = null;
- }
-
- void fireResponseErrorListener()
- {
- uiHandler.post(new Runnable() {
- @Override
- public void run() {
- try {
- if (listener != null) {
- listener.onResponseError();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
-
- private void fireApiListModifiedListener(final List<String> availableApis)
- {
- uiHandler.post(new Runnable() {
- @Override
- public void run() {
- try {
- if (listener != null) {
- listener.onApiListModified(availableApis);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
-
- private void fireCameraStatusChangeListener(final String status) {
- uiHandler.post(new Runnable() {
- @Override
- public void run() {
- try {
- if (listener != null) {
- listener.onCameraStatusChanged(status);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
-
- private void fireLiveviewStatusChangeListener(final boolean status) {
- uiHandler.post(new Runnable() {
- @Override
- public void run() {
- if (listener != null) {
- listener.onLiveviewStatusChanged(status);
- }
- }
- });
- }
-
- private void fireShootModeChangeListener(final String shootMode) {
- uiHandler.post(new Runnable() {
- @Override
- public void run() {
- if (listener != null) {
- listener.onShootModeChanged(shootMode);
- }
- }
- });
- }
-
- private void fireZoomInformationChangeListener(final int zoomIndexCurrentBox, final int zoomNumberBox, final int zoomPosition, final int zoomPositionCurrentBox) {
- uiHandler.post(new Runnable() {
- @Override
- public void run() {
- if (listener != null) {
- listener.onZoomPositionChanged(zoomPosition);
- }
- }
- });
- }
-
- private void fireStorageIdChangeListener(final String storageId) {
- uiHandler.post(new Runnable() {
- @Override
- public void run() {
- if (listener != null) {
- listener.onStorageIdChanged(storageId);
- }
- }
- });
- }
-
- private void fireFocusStatusChangeListener(final String focusStatus) {
- uiHandler.post(new Runnable() {
- @Override
- public void run() {
- if (listener != null) {
- listener.onFocusStatusChanged(focusStatus);
- }
- }
- });
- }
-
- private static List<String> findAvailableApiList(JSONObject replyJson) {
- List<String> availableApis = new ArrayList<>();
- int indexOfAvailableApiList = 0;
- try {
-
- JSONArray resultsObj = replyJson.getJSONArray("result");
- if (!resultsObj.isNull(indexOfAvailableApiList)) {
- JSONObject availableApiListObj = resultsObj.getJSONObject(indexOfAvailableApiList);
- String type = availableApiListObj.getString("type");
- if ("availableApiList".equals(type)) {
- JSONArray apiArray = availableApiListObj.getJSONArray("names");
- for (int i = 0; i < apiArray.length(); i++) {
- availableApis.add(apiArray.getString(i));
- }
- } else {
- Log.w(TAG, "Event reply: Illegal Index (0: AvailableApiList) " + type);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (availableApis);
- }
-
- private static String findCameraStatus(JSONObject replyJson)
- {
- String cameraStatus = null;
- int indexOfCameraStatus = 1;
- try {
- JSONArray resultsObj = replyJson.getJSONArray("result");
- if (!resultsObj.isNull(indexOfCameraStatus)) {
- JSONObject cameraStatusObj = resultsObj.getJSONObject(indexOfCameraStatus);
- String type = cameraStatusObj.getString("type");
- if ("cameraStatus".equals(type)) {
- cameraStatus = cameraStatusObj.getString("cameraStatus");
- } else {
- Log.w(TAG, "Event reply: Illegal Index (1: CameraStatus) " + type);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (cameraStatus);
- }
-
- private static Boolean findLiveviewStatus(JSONObject replyJson)
- {
- Boolean liveviewStatus = null;
- try {
- int indexOfLiveviewStatus = 3;
- JSONArray resultsObj = replyJson.getJSONArray("result");
- if (!resultsObj.isNull(indexOfLiveviewStatus)) {
- JSONObject liveviewStatusObj = resultsObj.getJSONObject(indexOfLiveviewStatus);
- String type = liveviewStatusObj.getString("type");
- if ("liveviewStatus".equals(type)) {
- liveviewStatus = liveviewStatusObj.getBoolean("liveviewStatus");
- } else {
- Log.w(TAG, "Event reply: Illegal Index (3: LiveviewStatus) " + type);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (liveviewStatus);
- }
-
-
- private static String findShootMode(JSONObject replyJson)
- {
- String shootMode = null;
- try {
- int indexOfShootMode = 21;
- JSONArray resultsObj = replyJson.getJSONArray("result");
- if (!resultsObj.isNull(indexOfShootMode)) {
- JSONObject shootModeObj = resultsObj.getJSONObject(indexOfShootMode);
- String type = shootModeObj.getString("type");
- if ("shootMode".equals(type)) {
- shootMode = shootModeObj.getString("currentShootMode");
- } else {
- Log.w(TAG, "Event reply: Illegal Index (21: ShootMode) " + type);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (shootMode);
- }
-
- private static List<String> findAvailableShootModes(JSONObject replyJson)
- {
- List<String> shootModes = new ArrayList<>();
- try {
- int indexOfShootMode = 21;
- JSONArray resultsObj = replyJson.getJSONArray("result");
- if (!resultsObj.isNull(indexOfShootMode)) {
- JSONObject shootModesObj = resultsObj.getJSONObject(indexOfShootMode);
- String type = shootModesObj.getString("type");
- if ("shootMode".equals(type)) {
- JSONArray shootModesArray = shootModesObj.getJSONArray("shootModeCandidates");
- if (shootModesArray != null) {
- for (int i = 0; i < shootModesArray.length(); i++) {
- shootModes.add(shootModesArray.getString(i));
- }
- }
- } else {
- Log.w(TAG, "Event reply: Illegal Index (21: ShootMode) " + type);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (shootModes);
- }
-
- private static int findZoomInformation(JSONObject replyJson)
- {
- int zoomPosition = -1;
- try {
- int indexOfZoomInformation = 2;
- JSONArray resultsObj = replyJson.getJSONArray("result");
- if (!resultsObj.isNull(indexOfZoomInformation)) {
- JSONObject zoomInformationObj = resultsObj.getJSONObject(indexOfZoomInformation);
- String type = zoomInformationObj.getString("type");
- if ("zoomInformation".equals(type)) {
- zoomPosition = zoomInformationObj.getInt("zoomPosition");
- } else {
- Log.w(TAG, "Event reply: Illegal Index (2: zoomInformation) " + type);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (zoomPosition);
- }
-
- private static String findStorageId(JSONObject replyJson)
- {
- String storageId = null;
- try {
- int indexOfStorageInfomation = 10;
- JSONArray resultsObj = replyJson.getJSONArray("result");
- if (!resultsObj.isNull(indexOfStorageInfomation)) {
- JSONArray storageInformationArray = resultsObj.getJSONArray(indexOfStorageInfomation);
- if (!storageInformationArray.isNull(0)) {
- JSONObject storageInformationObj = storageInformationArray.getJSONObject(0);
- String type = storageInformationObj.getString("type");
- if ("storageInformation".equals(type)) {
- storageId = storageInformationObj.getString("storageID");
- } else {
- Log.w(TAG, "Event reply: Illegal Index (11: storageInformation) " + type);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (storageId);
- }
-
- private static String findFocusStatus(JSONObject replyJson)
- {
- String focusStatus = null;
- try {
- int indexOfFocusStatus= 35;
- JSONArray resultsObj = replyJson.getJSONArray("result");
- if (!resultsObj.isNull(indexOfFocusStatus)) {
- JSONObject focustatusObj = resultsObj.getJSONObject(indexOfFocusStatus);
- String type = focustatusObj.getString("type");
- if ("focusStatus".equals(type)) {
- focusStatus = focustatusObj.getString("focusStatus");
- } else {
- Log.w(TAG, "Event reply: Illegal Index (21: ShootMode) " + type);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return (focusStatus);
- }
-
- @Override
- public String getCameraStatus()
- {
- return (cameraStatus);
- }
-
- @Override
- public boolean getLiveviewStatus()
- {
- return (currentLiveviewStatus);
- }
-
- @Override
- public String getShootMode()
- {
- return (currentShootMode);
- }
-
- @Override
- public List<String> getAvailableShootModes()
- {
- return (currentAvailableShootModes);
- }
-
- @Override
- public int getZoomPosition()
- {
- return (currentZoomPosition);
- }
-
- @Override
- public String getStorageId()
- {
- return (currentStorageId);
- }
-
-}
import net.osdn.gokigen.a01d.IChangeScene;
import net.osdn.gokigen.a01d.R;
-import net.osdn.gokigen.a01d.camera.panasonic.cameraproperty.PanasonicCameraApiListViewer;
import net.osdn.gokigen.a01d.camera.panasonic.operation.CameraPowerOffPanasonic;
import net.osdn.gokigen.a01d.logcat.LogCatViewer;
import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
private SharedPreferences preferences = null;
private CameraPowerOffPanasonic powerOffController = null;
private LogCatViewer logCatViewer = null;
- private PanasonicCameraApiListViewer cameraApiListViewer = null;
+ //private PanasonicCameraApiListViewer cameraApiListViewer = null;
/**
*
logCatViewer = new LogCatViewer(changeScene);
logCatViewer.prepare();
- cameraApiListViewer = new PanasonicCameraApiListViewer(changeScene);
- cameraApiListViewer.prepare();
+ //cameraApiListViewer = new PanasonicCameraApiListViewer(changeScene);
+ //cameraApiListViewer.prepare();
}
catch (Exception e)
{
findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
- findPreference("panasonic_api_list").setOnPreferenceClickListener(cameraApiListViewer);
+ //findPreference("panasonic_api_list").setOnPreferenceClickListener(cameraApiListViewer);
}
catch (Exception e)
{