OSDN Git Service

Ricoh Theta対応準備。(その1)
authorMRSa <mrsa@myad.jp>
Tue, 14 Jan 2020 15:15:52 +0000 (00:15 +0900)
committerMRSa <mrsa@myad.jp>
Tue, 14 Jan 2020 15:15:52 +0000 (00:15 +0900)
app/build.gradle
app/src/main/java/net/osdn/gokigen/pkremote/camera/utils/SimpleHttpClient.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/utils/SimpleHttpSendCommandDialog.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/theta/IThetaInterfaceProvider.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/theta/operation/ThetaCameraPowerOff.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/preference/theta/ThetaPreferenceFragment.java [new file with mode: 0644]
app/src/main/res/layout/http_request_layout.xml [new file with mode: 0644]
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/strings.xml
app/src/main/res/xml/preferences_theta.xml [new file with mode: 0644]

index 825e469..090cad9 100644 (file)
@@ -6,8 +6,8 @@ android {
         applicationId "net.osdn.gokigen.pkremote"
         minSdkVersion 14
         targetSdkVersion 29
-        versionCode 10603
-        versionName "1.6.3"
+        versionCode 10700
+        versionName "1.7.0"
     }
     buildTypes {
         release {
index 4752d6a..b2c8d40 100644 (file)
@@ -376,6 +376,16 @@ public class SimpleHttpClient
      *
      *
      */
+    public static String httpPutWithHeader(String url, String putData, Map<String, String> headerMap, String contentType, int timeoutMs)
+    {
+        return (httpCommand(url, "PUT", putData, headerMap, contentType, timeoutMs));
+    }
+
+    /**
+     *
+     *
+     *
+     */
     public static String httpPut(String url, String postData, int timeoutMs)
     {
         return (httpCommand(url, "PUT", postData, null, null, timeoutMs));
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/utils/SimpleHttpSendCommandDialog.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/utils/SimpleHttpSendCommandDialog.java
new file mode 100644 (file)
index 0000000..94cf0f5
--- /dev/null
@@ -0,0 +1,305 @@
+package net.osdn.gokigen.pkremote.camera.utils;
+
+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.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
+
+import net.osdn.gokigen.pkremote.R;
+import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewControl;
+
+import java.util.Map;
+
+public class SimpleHttpSendCommandDialog extends DialogFragment implements View.OnClickListener
+{
+    private final String TAG = toString();
+    private ILiveViewControl liveViewControl = null;
+    private Dialog myDialog = null;
+    private EditText method = null;
+    private EditText service = null;
+    private EditText parameter = null;
+    private EditText command = null;
+    private TextView responseArea = null;
+    private String urlToSend = null;
+    private Map<String, String> headerMap;
+
+    private static final int TIMEOUT_MS = 6000;
+    private static final String COMMUNICATE_URL_DEFAULT = "http://192.168.0.10/";
+
+    /**
+     *
+     *
+     */
+    public static SimpleHttpSendCommandDialog newInstance(@Nullable String urlToSend, @NonNull ILiveViewControl liveViewControl,  @Nullable Map<String, String> headerMap)
+    {
+        SimpleHttpSendCommandDialog instance = new SimpleHttpSendCommandDialog();
+        instance.prepare(urlToSend, liveViewControl, headerMap);
+
+        // パラメータはBundleにまとめておく
+        Bundle arguments = new Bundle();
+        //arguments.putString("method", method);
+        //arguments.putString("message", message);
+        instance.setArguments(arguments);
+
+        return (instance);
+    }
+
+    /**
+     *
+     *
+     */
+    private void prepare(@Nullable String urlToSend, @NonNull ILiveViewControl liveViewControl, @Nullable Map<String, String> headerMap)
+    {
+        if ((urlToSend == null)||(!urlToSend.contains("http://")))
+        {
+            this.urlToSend = COMMUNICATE_URL_DEFAULT;
+        }
+        else
+        {
+            this.urlToSend = urlToSend;
+        }
+
+        //
+        this.liveViewControl = liveViewControl;
+
+        this.headerMap = headerMap;
+        //headerMap = new HashMap<>();
+        //headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
+        //headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
+    }
+
+    @Override
+    public void onPause()
+    {
+        super.onPause();
+        Log.v(TAG, "AlertDialog::onPause()");
+        try
+        {
+            if (myDialog != null)
+            {
+                myDialog.cancel();
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public @NonNull Dialog onCreateDialog(Bundle savedInstanceState)
+    {
+        final Activity activity = getActivity();
+
+        // コマンド送信ダイアログの生成
+        final AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
+
+        // Get the layout inflater
+        LayoutInflater inflater = activity.getLayoutInflater();
+        final View alertView = inflater.inflate(R.layout.http_request_layout, null, false);
+        alertDialog.setView(alertView);
+
+        alertDialog.setIcon(R.drawable.ic_linked_camera_black_24dp);
+        alertDialog.setTitle(activity.getString(R.string.dialog_http_command_title_command));
+        method = alertView.findViewById(R.id.edit_method);
+        service = alertView.findViewById(R.id.edit_service);
+        parameter = alertView.findViewById(R.id.edit_parameter);
+        command = alertView.findViewById(R.id.edit_command);
+        responseArea = alertView.findViewById(R.id.olympuspen_command_response_value);
+        final Button sendButton = alertView.findViewById(R.id.send_message_button);
+        final Button toRunningButton = alertView.findViewById(R.id.change_to_liveview);
+        final Button toPlaybackButton = alertView.findViewById(R.id.change_to_playback);
+
+        toRunningButton.setOnClickListener(this);
+        toPlaybackButton.setOnClickListener(this);
+        sendButton.setOnClickListener(this);
+        alertDialog.setCancelable(true);
+        try
+        {
+            if (method != null)
+            {
+                method.setText(activity.getText(R.string.http_method_string));
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+
+        // ボタンを設定する(実行ボタン)
+        alertDialog.setPositiveButton(activity.getString(R.string.dialog_positive_execute),
+                new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int which)
+                    {
+                        dialog.dismiss();
+                    }
+                });
+
+        // ボタンを設定する (キャンセルボタン)
+        alertDialog.setNegativeButton(activity.getString(R.string.dialog_negative_cancel),
+                new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int which) {
+                        dialog.cancel();
+                    }
+                });
+
+        // 確認ダイアログを応答する
+        myDialog = alertDialog.create();
+        return (myDialog);
+    }
+
+    private void changeRunMode(boolean isStartLiveView)
+    {
+        // ライブビューの停止と開始
+        Log.v(TAG, "changeRunMode() : " + isStartLiveView);
+        if (liveViewControl == null)
+        {
+            Log.v(TAG, "liveViewControl is NULL...");
+            return;
+        }
+        try
+        {
+            if (isStartLiveView)
+            {
+                liveViewControl.startLiveView(false);
+            }
+            else
+            {
+                liveViewControl.stopLiveView();
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void onClick(View view)
+    {
+        if (view.getId() == R.id.change_to_liveview)
+        {
+            changeRunMode(true);
+            return;
+        }
+        if (view.getId() == R.id.change_to_playback)
+        {
+            changeRunMode(false);
+            return;
+        }
+
+
+        try
+        {
+            String methodStr = "";
+            String serviceStr = "";
+            String commandStr = "";
+            String parameterStr = "";
+            final Activity activity = getActivity();
+            if (activity != null)
+            {
+                if (method != null)
+                {
+                    methodStr = method.getText().toString().toLowerCase();
+                }
+                final boolean isPost = (methodStr.contains("post"));
+                final boolean isPut = (methodStr.contains("put"));
+
+                if (service != null)
+                {
+                    serviceStr = service.getText().toString();
+                }
+                if (command != null)
+                {
+                    commandStr = command.getText().toString();
+                }
+                if (parameter != null)
+                {
+                    // GET メソッドのときは、 commandStr と parameterStrを結合する。
+                    parameterStr = parameter.getText().toString();
+                    if ((!isPost)&&(parameterStr.length() > 0))
+                    {
+                        commandStr = commandStr + "&" + parameterStr;
+                    }
+                }
+
+                //  > GET  : http://xxx.xxx.xxx.xxx/(serviceStr) + "?" (commandStr) + "&" (parameterStr)
+                //  > POST : http://xxx.xxx.xxx.xxx/(serviceStr) + "?" (commandStr) , parameterStr ← BODY
+                if (commandStr.length() > 0)
+                {
+                    serviceStr = urlToSend + serviceStr + "?" + commandStr;
+                }
+                else
+                {
+                    // commandStrにデータが記入されていない場合はServiceStrのみ
+                    serviceStr = urlToSend + serviceStr;
+                }
+
+                final String url = serviceStr;
+                final String param = parameterStr;
+
+                Thread thread = new Thread(new Runnable() {
+                    @Override
+                    public void run()
+                    {
+                        try
+                        {
+                            String reply;
+                            if (isPost)
+                            {
+                                reply =  SimpleHttpClient.httpPostWithHeader(url, param, headerMap, null, TIMEOUT_MS);
+                            }
+                            else if (isPut)
+                            {
+                                reply =  SimpleHttpClient.httpPutWithHeader(url, param, headerMap, null, TIMEOUT_MS);
+                            }
+                            else
+                            {
+                                reply = SimpleHttpClient.httpGetWithHeader(url, headerMap, null, TIMEOUT_MS);
+                            }
+                            Log.v(TAG, "URL : " + url + " RESPONSE : " + reply);
+                            final String response = reply;
+                            activity.runOnUiThread(new Runnable() {
+                                @Override
+                                public void run() {
+                                    if (responseArea != null)
+                                    {
+                                        responseArea.setText(response);
+                                    }
+                                }
+                            });
+                        }
+                        catch (Exception e)
+                        {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+                thread.start();
+            }
+            else
+            {
+                Log.v(TAG, "getActivity() Fail...");
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+}
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/theta/IThetaInterfaceProvider.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/theta/IThetaInterfaceProvider.java
new file mode 100644 (file)
index 0000000..11c08c1
--- /dev/null
@@ -0,0 +1,42 @@
+package net.osdn.gokigen.pkremote.camera.vendor.theta;
+
+import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraButtonControl;
+import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection;
+import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode;
+import net.osdn.gokigen.pkremote.camera.interfaces.control.ICaptureControl;
+import net.osdn.gokigen.pkremote.camera.interfaces.control.IFocusingControl;
+import net.osdn.gokigen.pkremote.camera.interfaces.control.IZoomLensControl;
+import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ICameraStatusUpdateNotify;
+import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IDisplayInjector;
+import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewControl;
+import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewListener;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
+import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus;
+import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraInformation;
+import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatus;
+import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusWatcher;
+import net.osdn.gokigen.pkremote.camera.vendor.panasonic.wrapper.IPanasonicCamera;
+
+public interface IThetaInterfaceProvider
+{
+    ICameraConnection getThetaCameraConnection();
+    ILiveViewControl getThetaLiveViewControl();
+
+    ILiveViewListener getLiveViewListener();
+    IFocusingControl getFocusingControl();
+    ICameraInformation getCameraInformation();
+    IZoomLensControl getZoomLensControl();
+    ICaptureControl getCaptureControl();
+    IDisplayInjector getDisplayInjector();
+
+    ICameraStatusUpdateNotify getStatusListener();
+
+    ICameraStatusWatcher getCameraStatusWatcher();
+    ICameraStatus getCameraStatusListHolder();
+
+    ICameraButtonControl getButtonControl();
+
+    IPlaybackControl getPlaybackControl();
+    ICameraHardwareStatus getHardwareStatus();
+    ICameraRunMode getCameraRunMode();
+}
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/theta/operation/ThetaCameraPowerOff.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/theta/operation/ThetaCameraPowerOff.java
new file mode 100644 (file)
index 0000000..8fec981
--- /dev/null
@@ -0,0 +1,81 @@
+package net.osdn.gokigen.pkremote.camera.vendor.theta.operation;
+
+
+import android.content.Context;
+
+import net.osdn.gokigen.pkremote.R;
+import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
+import net.osdn.gokigen.pkremote.scene.ConfirmationDialog;
+import net.osdn.gokigen.pkremote.scene.IChangeScene;
+
+import androidx.preference.Preference;
+
+/**
+ *  Preferenceがクリックされた時に処理するクラス
+ *
+ */
+public class ThetaCameraPowerOff implements Preference.OnPreferenceClickListener, ConfirmationDialog.Callback
+{
+    private final Context context;
+    private final IChangeScene changeScene;
+    private String preferenceKey = null;
+
+    /**
+     *   コンストラクタ
+     *
+     */
+    public ThetaCameraPowerOff(Context context, IChangeScene changeScene)
+    {
+        this.context = context;
+        this.changeScene = changeScene;
+    }
+
+    /**
+     *   クラスの準備
+     *
+     */
+    public void prepare()
+    {
+        // 何もしない
+    }
+
+    /**
+     *
+     *
+     * @param preference クリックしたpreference
+     * @return false : ハンドルしない / true : ハンドルした
+     */
+    @Override
+    public boolean onPreferenceClick(Preference preference)
+    {
+        if (!preference.hasKey())
+        {
+            return (false);
+        }
+
+        preferenceKey = preference.getKey();
+        if (preferenceKey.contains(IPreferencePropertyAccessor.EXIT_APPLICATION))
+        {
+
+            // 確認ダイアログの生成と表示
+            ConfirmationDialog dialog = ConfirmationDialog.newInstance(context);
+            dialog.show(R.string.dialog_title_confirmation, R.string.dialog_message_exit_application, this);
+            return (true);
+        }
+        return (false);
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public void confirm()
+    {
+        if (preferenceKey.contains(IPreferencePropertyAccessor.EXIT_APPLICATION))
+        {
+            // カメラの電源をOFFにしたうえで、アプリケーションを終了する。
+            changeScene.exitApplication();
+        }
+    }
+}
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/preference/theta/ThetaPreferenceFragment.java b/app/src/main/java/net/osdn/gokigen/pkremote/preference/theta/ThetaPreferenceFragment.java
new file mode 100644 (file)
index 0000000..48d26e1
--- /dev/null
@@ -0,0 +1,351 @@
+package net.osdn.gokigen.pkremote.preference.theta;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.CheckBoxPreference;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.PreferenceManager;
+
+import net.osdn.gokigen.pkremote.R;
+import net.osdn.gokigen.pkremote.camera.vendor.theta.operation.ThetaCameraPowerOff;
+import net.osdn.gokigen.pkremote.logcat.LogCatViewer;
+import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
+import net.osdn.gokigen.pkremote.scene.IChangeScene;
+
+import java.util.Map;
+
+import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.DEBUG_INFO;
+import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.EXIT_APPLICATION;
+import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.WIFI_SETTINGS;
+
+/**
+ *
+ *
+ */
+public class ThetaPreferenceFragment  extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener
+{
+    private final String TAG = toString();
+    private AppCompatActivity context = null;
+    private SharedPreferences preferences = null;
+    private ThetaCameraPowerOff powerOffController = null;
+    private LogCatViewer logCatViewer = null;
+
+    /**
+     *
+     *
+     */
+    public static ThetaPreferenceFragment newInstance(@NonNull AppCompatActivity context, @NonNull IChangeScene changeScene)
+    {
+        ThetaPreferenceFragment instance = new ThetaPreferenceFragment();
+        instance.prepare(context, changeScene);
+
+        // パラメータはBundleにまとめておく
+        Bundle arguments = new Bundle();
+        //arguments.putString("title", title);
+        //arguments.putString("message", message);
+        instance.setArguments(arguments);
+
+        return (instance);
+    }
+
+    /**
+     *
+     *
+     */
+    private void prepare(@NonNull AppCompatActivity context, @NonNull IChangeScene changeScene)
+    {
+        try
+        {
+            powerOffController = new ThetaCameraPowerOff(context, changeScene);
+            powerOffController.prepare();
+
+            logCatViewer = new LogCatViewer(changeScene);
+            logCatViewer.prepare();
+
+            //cameraApiListViewer = new PanasonicCameraApiListViewer(changeScene);
+            //cameraApiListViewer.prepare();
+
+            this.context = context;
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public void onAttach(@NonNull Context activity)
+    {
+        super.onAttach(activity);
+        Log.v(TAG, "onAttach()");
+
+        try
+        {
+            // Preference をつかまえる
+            preferences = PreferenceManager.getDefaultSharedPreferences(activity);
+
+            // Preference を初期設定する
+            initializePreferences();
+
+            preferences.registerOnSharedPreferenceChangeListener(this);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Preferenceの初期化...
+     *
+     */
+    private void initializePreferences()
+    {
+        try
+        {
+            Map<String, ?> items = preferences.getAll();
+            SharedPreferences.Editor editor = preferences.edit();
+
+            if (!items.containsKey(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA)) {
+                editor.putBoolean(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
+            }
+            if (!items.containsKey(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW)) {
+                editor.putBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true);
+            }
+            if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) {
+                editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
+            }
+            editor.apply();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
+    {
+        Log.v(TAG, "onSharedPreferenceChanged() : " + key);
+        boolean value;
+        if (key != null)
+        {
+            switch (key)
+            {
+                case IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA:
+                    value = preferences.getBoolean(key, true);
+                    Log.v(TAG, " " + key + " , " + value);
+                    break;
+
+                case IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW:
+                    value = preferences.getBoolean(key, true);
+                    Log.v(TAG, " " + key + " , " + value);
+                    break;
+
+                default:
+                    String strValue = preferences.getString(key, "");
+                    setListPreference(key, key, strValue);
+                    break;
+            }
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public void onCreatePreferences(Bundle savedInstanceState, String rootKey)
+    {
+        Log.v(TAG, "onCreatePreferences()");
+        try
+        {
+            //super.onCreate(savedInstanceState);
+            addPreferencesFromResource(R.xml.preferences_panasonic);
+
+            ListPreference connectionMethod = findPreference(IPreferencePropertyAccessor.CONNECTION_METHOD);
+            connectionMethod.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+                @Override
+                public boolean onPreferenceChange(Preference preference, Object newValue) {
+                    preference.setSummary(newValue + " ");
+                    return (true);
+                }
+            });
+            connectionMethod.setSummary(connectionMethod.getValue() + " ");
+
+            findPreference(EXIT_APPLICATION).setOnPreferenceClickListener(powerOffController);
+            findPreference(DEBUG_INFO).setOnPreferenceClickListener(logCatViewer);
+            findPreference(WIFI_SETTINGS).setOnPreferenceClickListener(this);
+            //findPreference("panasonic_api_list").setOnPreferenceClickListener(cameraApiListViewer);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public void onResume()
+    {
+        super.onResume();
+        Log.v(TAG, "onResume() Start");
+
+        try
+        {
+            synchronizedProperty();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+
+        Log.v(TAG, "onResume() End");
+
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public void onPause()
+    {
+        super.onPause();
+        Log.v(TAG, "onPause() Start");
+
+        try
+        {
+            // Preference変更のリスナを解除
+            preferences.unregisterOnSharedPreferenceChangeListener(this);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+
+        Log.v(TAG, "onPause() End");
+    }
+
+    /**
+     * ListPreference の表示データを設定
+     *
+     * @param pref_key     Preference(表示)のキー
+     * @param key          Preference(データ)のキー
+     * @param defaultValue Preferenceのデフォルト値
+     */
+    private void setListPreference(String pref_key, String key, String defaultValue)
+    {
+        try
+        {
+            ListPreference pref;
+            pref = findPreference(pref_key);
+            String value = preferences.getString(key, defaultValue);
+            if (pref != null)
+            {
+                pref.setValue(value);
+                pref.setSummary(value);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * BooleanPreference の表示データを設定
+     *
+     * @param pref_key     Preference(表示)のキー
+     * @param key          Preference(データ)のキー
+     * @param defaultValue Preferenceのデフォルト値
+     */
+    private void setBooleanPreference(String pref_key, String key, boolean defaultValue)
+    {
+        try
+        {
+            CheckBoxPreference pref = findPreference(pref_key);
+            if (pref != null) {
+                boolean value = preferences.getBoolean(key, defaultValue);
+                pref.setChecked(value);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *
+     *
+     */
+    private void synchronizedProperty()
+    {
+        final FragmentActivity activity = getActivity();
+        final boolean defaultValue = true;
+        if (activity != null)
+        {
+            activity.runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    try
+                    {
+                        // Preferenceの画面に反映させる
+                        setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, defaultValue);
+                        setBooleanPreference(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, defaultValue);
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
+        }
+    }
+
+    @Override
+    public boolean onPreferenceClick(Preference preference)
+    {
+        try
+        {
+            String preferenceKey = preference.getKey();
+            if (preferenceKey.contains(WIFI_SETTINGS))
+            {
+                // Wifi 設定画面を表示する
+                Log.v(TAG, " onPreferenceClick : " + preferenceKey);
+                if (context != null)
+                {
+                    context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+                }
+            }
+            return (true);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+}
diff --git a/app/src/main/res/layout/http_request_layout.xml b/app/src/main/res/layout/http_request_layout.xml
new file mode 100644 (file)
index 0000000..e6f3f93
--- /dev/null
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+        <LinearLayout
+            android:id="@+id/info_edit_data"
+            android:orientation="vertical"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:padding="6dp"
+            >
+            <LinearLayout
+                android:id="@+id/mode_change_button_area"
+                android:orientation="horizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:padding="6dp"
+                >
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:tag="button"
+                    android:id="@+id/change_to_liveview"
+                    android:text="@string/dialog_button_liveview"
+                    android:layout_gravity="center"
+                    android:visibility="visible"
+                    android:textSize="6pt" />
+
+                <Button
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:tag="button"
+                    android:id="@+id/change_to_playback"
+                    android:text="@string/dialog_button_playback"
+                    android:layout_gravity="center"
+                    android:visibility="visible"
+                    android:textSize="6pt" />
+            </LinearLayout>
+
+            <TextView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/method_name"
+                android:tag="title"
+                android:maxWidth="130dp"
+                android:minWidth="130dp"
+                android:layout_gravity="start">
+            </TextView>
+
+            <EditText android:id="@+id/edit_method"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/http_dialog_method_hint"
+                />
+
+            <EditText android:id="@+id/edit_service"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/http_dialog_service_hint"
+                />
+
+            <EditText android:id="@+id/edit_command"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/http_dialog_command_hint"
+                />
+
+            <EditText android:id="@+id/edit_parameter"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:autoLink="all"
+                android:linksClickable="true"
+                android:inputType="text"
+                android:hint="@string/http_dialog_parameter_hint"
+                />
+
+            <Button
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:tag="button"
+                android:id="@+id/send_message_button"
+                android:text="@string/dialog_send_message"
+                android:layout_gravity="center"
+                android:textSize="6pt" />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="2dp"
+                android:background="@android:color/darker_gray"/>
+
+            <TextView
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/olympuspen_command_response_value"
+                android:text="@string/blank"
+                />
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="2dp"
+                android:background="@android:color/darker_gray"/>
+
+        </LinearLayout>
+    </ScrollView>
+</LinearLayout>
index 676d5d0..c9184a4 100644 (file)
     <string name="action_share">共有</string>
     <string name="free_method_name">(Method Name)</string>
 
+    <string name="pref_exit_power_off_theta">アプリ終了</string>
     <string name="pref_exit_power_off_panasonic">アプリ終了</string>
     <string name="pref_exit_power_off_sony">アプリ終了</string>
     <string name="pref_summary_sony_api_list">カメラのAPI一覧を表示します。</string>
     <string name="pref_canon_receive_wait">応答受信待ち時間(単位:ms)</string>
     <string name="pref_summary_canon_receive_wait">おかしい場合に値を大きくします</string>
 
+    <string name="dialog_http_command_title_command">HTTP送信</string>
+    <string name="http_dialog_method_hint">GET/POST/PUT</string>
+    <string name="http_dialog_service_hint">(service)</string>
+    <string name="http_dialog_command_hint">(command)</string>
+    <string name="http_dialog_parameter_hint">(parameter)</string>
+    <string name="http_method_string">GET</string>
+
 </resources>
index 7c72924..f48a673 100644 (file)
     <string name="action_share">Share</string>
     <string name="free_method_name">()</string>
 
+    <string name="pref_exit_power_off_theta">Exit Application</string>
     <string name="pref_exit_power_off_panasonic">Exit Application</string>
     <string name="pref_exit_power_off_sony">Exit Application</string>
     <string name="pref_summary_sony_api_list">Show available camera apis.</string>
     <string name="pref_canon_receive_wait">Receive reply wait(ms)</string>
     <string name="pref_summary_canon_receive_wait"> </string>
 
+    <string name="dialog_http_command_title_command">HTTP Send Message</string>
+    <string name="http_dialog_method_hint">GET/POST/PUT</string>
+    <string name="http_dialog_service_hint">(service)</string>
+    <string name="http_dialog_command_hint">(command)</string>
+    <string name="http_dialog_parameter_hint">(parameter)</string>
+    <string name="http_method_string">GET</string>
+
 </resources>
diff --git a/app/src/main/res/xml/preferences_theta.xml b/app/src/main/res/xml/preferences_theta.xml
new file mode 100644 (file)
index 0000000..7351c73
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+    <PreferenceCategory
+        android:title="@string/pref_cat_application_control">
+
+        <PreferenceScreen
+            android:key="exit_application"
+            android:icon="@drawable/ic_power_settings_new_black_24dp"
+            android:title="@string/pref_exit_power_off_theta" />
+
+        <ListPreference
+            android:title="@string/pref_connection_method"
+            android:entryValues="@array/connection_method_value"
+            android:entries="@array/connection_method"
+            android:key="connection_method"
+            android:defaultValue="OPC"/>
+
+        <PreferenceScreen
+            android:key="wifi_settings"
+            android:title="@string/pref_wifi_settings"
+            android:summary="@string/pref_summary_wifi_settings" />
+
+    </PreferenceCategory>
+
+<!--
+    <PreferenceCategory
+        android:title="@string/pref_cat_camera">
+
+        <CheckBoxPreference
+            android:key="capture_both_camera_and_live_view"
+            android:title="@string/pref_capture_both_camera_and_live_view" />
+
+    </PreferenceCategory>
+-->
+
+    <PreferenceCategory
+        android:title="@string/pref_cat_initialize">
+
+        <CheckBoxPreference
+        android:key="auto_connect_to_camera"
+        android:title="@string/pref_auto_connect_camera"
+        android:summary="@string/pref_summary_auto_connect_camera" />
+    </PreferenceCategory>
+
+    <PreferenceCategory
+        android:title="@string/pref_cat_gokigen">
+
+        <Preference
+            android:key="instruction_link"
+            android:title="@string/pref_instruction_manual"
+            android:summary="https://osdn.net/projects/gokigen/wiki/PKRemote"
+            android:selectable="true">
+            <intent android:action="android.intent.action.VIEW"
+                android:data="https://osdn.net/projects/gokigen/wiki/PKRemote" />
+        </Preference>
+
+        <Preference
+            android:key="privacy_policy"
+            android:title="@string/pref_privacy_policy"
+            android:summary="https://osdn.net/projects/gokigen/wiki/PrivacyPolicy"
+            android:selectable="true">
+            <intent android:action="android.intent.action.VIEW"
+                android:data="https://osdn.net/projects/gokigen/wiki/PrivacyPolicy" />
+        </Preference>
+
+        <PreferenceScreen
+            android:key="debug_info"
+            android:title="@string/pref_degug_info"
+            android:summary="@string/pref_summary_debug_info" />
+
+    </PreferenceCategory>
+</PreferenceScreen>