• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

OPC(Olympus Air)用望遠鏡アプリ。


Commit MetaInfo

Révision8b1e08263d3b01470b638c66004c99dbca253b50 (tree)
l'heure2018-07-05 00:41:33
AuteurMRSa <mrsa@myad...>
CommiterMRSa

Message de Log

カメラに接続したとき、画面表示タイプの制御を追加。

Change Summary

Modification

--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/wrapper/connection/RicohGr2CameraConnectSequence.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/wrapper/connection/RicohGr2CameraConnectSequence.java
@@ -1,6 +1,8 @@
11 package net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.connection;
22
33 import android.app.Activity;
4+import android.content.SharedPreferences;
5+import android.preference.PreferenceManager;
46 import android.support.annotation.NonNull;
57 import android.util.Log;
68
@@ -8,6 +10,7 @@ import net.osdn.gokigen.a01d.R;
810 import net.osdn.gokigen.a01d.camera.ICameraConnection;
911 import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
1012 import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
13+import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
1114
1215 class RicohGr2CameraConnectSequence implements Runnable
1316 {
@@ -28,6 +31,7 @@ class RicohGr2CameraConnectSequence implements Runnable
2831 public void run()
2932 {
3033 final String areYouThereUrl = "http://192.168.0.1/v1/ping";
34+ final String grCommandUrl = "http://192.168.0.1/_gr";
3135 final int TIMEOUT_MS = 5000;
3236 try
3337 {
@@ -35,6 +39,43 @@ class RicohGr2CameraConnectSequence implements Runnable
3539 Log.v(TAG, areYouThereUrl + " " + response);
3640 if (response.length() > 0)
3741 {
42+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
43+
44+ // 接続時、カメラの画面を消す
45+ if (preferences.getBoolean(IPreferencePropertyAccessor.GR2_LCD_SLEEP, false))
46+ {
47+ final String postData = "cmd=lcd sleep on";
48+ String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
49+ Log.v(TAG, grCommandUrl + " " + response0);
50+ }
51+
52+ // 表示するディスプレイモードを切り替える
53+ String dispMode = preferences.getString(IPreferencePropertyAccessor.GR2_DISPLAY_MODE, IPreferencePropertyAccessor.GR2_DISPLAY_MODE_DEFAULT_VALUE);
54+ if (dispMode.contains("1"))
55+ {
56+ // Disp. ボタンを 1回 押す
57+ final String postData = "cmd=bdisp";
58+ String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
59+ Log.v(TAG, grCommandUrl + " " + response0);
60+
61+ }
62+ else if (dispMode.contains("2"))
63+ {
64+ // Disp. ボタンを 2回 押す
65+ final String postData = "cmd=bdisp";
66+ String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
67+ String response1 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
68+ Log.v(TAG, grCommandUrl + " " + response0 + " " + response1);
69+ }
70+ else if (dispMode.contains("3"))
71+ {
72+ // Disp. ボタンを 3回 押す
73+ final String postData = "cmd=bdisp";
74+ String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
75+ String response1 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
76+ String response2 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
77+ Log.v(TAG, grCommandUrl + " " + response0 + " " + response1 + response2);
78+ }
3879 onConnectNotify();
3980 }
4081 else
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/wrapper/connection/RicohGr2CameraDisconnectSequence.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/wrapper/connection/RicohGr2CameraDisconnectSequence.java
@@ -1,16 +1,22 @@
11 package net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.connection;
22
3+import android.app.Activity;
4+import android.content.SharedPreferences;
5+import android.preference.PreferenceManager;
36 import android.util.Log;
47
58 import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
9+import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
610
711 public class RicohGr2CameraDisconnectSequence implements Runnable
812 {
913 private final String TAG = this.toString();
14+ private final Activity activity;
1015 private final boolean powerOff;
1116
12- RicohGr2CameraDisconnectSequence(boolean isOff)
17+ RicohGr2CameraDisconnectSequence(Activity activity, boolean isOff)
1318 {
19+ this.activity = activity;
1420 this.powerOff = isOff;
1521 }
1622
@@ -20,6 +26,16 @@ public class RicohGr2CameraDisconnectSequence implements Runnable
2026 // カメラをPowerOffして接続を切る
2127 try
2228 {
29+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
30+ if (preferences.getBoolean(IPreferencePropertyAccessor.GR2_LCD_SLEEP, false))
31+ {
32+ final String screenOnUrl = "http://192.168.0.1/_gr";
33+ final String postData = "lcd sleep off";
34+ final int TIMEOUT_MS = 5000;
35+ String response = SimpleHttpClient.httpPost(screenOnUrl, postData, TIMEOUT_MS);
36+ Log.v(TAG, screenOnUrl + " " + response);
37+ }
38+
2339 if (powerOff)
2440 {
2541 final String cameraPowerOffUrl = "http://192.168.0.1/v1/device/finish";
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/wrapper/connection/RicohGr2Connection.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ricohgr2/wrapper/connection/RicohGr2Connection.java
@@ -241,7 +241,7 @@ public class RicohGr2Connection implements ICameraConnection
241241 Log.v(TAG, "disconnectFromCamera()");
242242 try
243243 {
244- cameraExecutor.execute(new RicohGr2CameraDisconnectSequence(powerOff));
244+ cameraExecutor.execute(new RicohGr2CameraDisconnectSequence(context, powerOff));
245245 }
246246 catch (Exception e)
247247 {
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/utils/SimpleLiveviewSlicer.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/utils/SimpleLiveviewSlicer.java
@@ -135,6 +135,7 @@ public class SimpleLiveviewSlicer
135135 catch (Exception e)
136136 {
137137 e.printStackTrace();
138+ System.gc();
138139 }
139140 return (payload);
140141 }
@@ -297,7 +298,7 @@ public class SimpleLiveviewSlicer
297298 searchIndex = 0;
298299 }
299300 }
300- catch (Exception e)
301+ catch (Throwable e)
301302 {
302303 Log.v(TAG, "INPUT STREAM EXCEPTION : " + e.getLocalizedMessage());
303304 // e.printStackTrace();
--- a/app/src/main/java/net/osdn/gokigen/a01d/preference/IPreferencePropertyAccessor.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/preference/IPreferencePropertyAccessor.java
@@ -43,8 +43,12 @@ public interface IPreferencePropertyAccessor
4343 String CONNECTION_METHOD = "connection_method";
4444 String CONNECTION_METHOD_DEFAULT_VALUE = "OPC";
4545
46+ String GR2_DISPLAY_MODE = "gr2_display_mode";
47+ String GR2_DISPLAY_MODE_DEFAULT_VALUE = "0";
4648
47-/*
49+ String GR2_LCD_SLEEP = "gr2_lcd_sleep";
50+
51+ /*
4852 int CHOICE_SPLASH_SCREEN = 10;
4953
5054 int SELECT_SAMPLE_IMAGE_CODE = 110;
--- a/app/src/main/java/net/osdn/gokigen/a01d/preference/ricohgr2/RicohGr2PreferenceFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/preference/ricohgr2/RicohGr2PreferenceFragment.java
@@ -113,6 +113,12 @@ public class RicohGr2PreferenceFragment extends PreferenceFragmentCompat implem
113113 if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) {
114114 editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
115115 }
116+ if (!items.containsKey(IPreferencePropertyAccessor.GR2_LCD_SLEEP)) {
117+ editor.putBoolean(IPreferencePropertyAccessor.GR2_LCD_SLEEP, false);
118+ }
119+ if (!items.containsKey(IPreferencePropertyAccessor.GR2_DISPLAY_MODE)) {
120+ editor.putString(IPreferencePropertyAccessor.GR2_DISPLAY_MODE, IPreferencePropertyAccessor.GR2_DISPLAY_MODE_DEFAULT_VALUE);
121+ }
116122 editor.apply();
117123 }
118124 catch (Exception e)
@@ -144,6 +150,11 @@ public class RicohGr2PreferenceFragment extends PreferenceFragmentCompat implem
144150 Log.v(TAG, " " + key + " , " + value);
145151 break;
146152
153+ case IPreferencePropertyAccessor.GR2_LCD_SLEEP:
154+ value = preferences.getBoolean(key, false);
155+ Log.v(TAG, " " + key + " , " + value);
156+ break;
157+
147158 default:
148159 String strValue = preferences.getString(key, "");
149160 setListPreference(key, key, strValue);
@@ -175,6 +186,16 @@ public class RicohGr2PreferenceFragment extends PreferenceFragmentCompat implem
175186 });
176187 connectionMethod.setSummary(connectionMethod.getValue() + " ");
177188
189+ ListPreference displayMode = (ListPreference) findPreference(IPreferencePropertyAccessor.GR2_DISPLAY_MODE);
190+ displayMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
191+ @Override
192+ public boolean onPreferenceChange(Preference preference, Object newValue) {
193+ preference.setSummary(newValue + " ");
194+ return (true);
195+ }
196+ });
197+ displayMode.setSummary(displayMode.getValue() + " ");
198+
178199 findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
179200 findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
180201 }
@@ -297,6 +318,8 @@ public class RicohGr2PreferenceFragment extends PreferenceFragmentCompat implem
297318 // Preferenceの画面に反映させる
298319 setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, defaultValue);
299320 setBooleanPreference(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, defaultValue);
321+ setBooleanPreference(IPreferencePropertyAccessor.GR2_LCD_SLEEP, IPreferencePropertyAccessor.GR2_LCD_SLEEP, defaultValue);
322+
300323 }
301324 catch (Exception e)
302325 {
@@ -306,5 +329,4 @@ public class RicohGr2PreferenceFragment extends PreferenceFragmentCompat implem
306329 });
307330 }
308331 }
309-
310332 }
--- a/app/src/main/res/values-ja/arrays.xml
+++ b/app/src/main/res/values-ja/arrays.xml
@@ -110,4 +110,20 @@
110110 <item >RICOH_GR2</item>
111111 </string-array>
112112
113+
114+ <string-array name="gr2_display_mode">
115+ <item >0</item>
116+ <item >1</item>
117+ <item >2</item>
118+ <item >3</item>
119+ </string-array>
120+
121+ <string-array name="gr2_display_mode_value">
122+ <item >0</item>
123+ <item >1</item>
124+ <item >2</item>
125+ <item >3</item>
126+ </string-array>
127+
128+
113129 </resources>
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -121,5 +121,7 @@
121121 <string name="camera_found">発見 : </string>
122122 <string name="camera_not_found">カメラ未発見</string>
123123 <string name="pref_connection_method">接続方式</string>
124+ <string name="pref_gr2_display_mode">ディスプレイモード</string>
125+ <string name="pref_gr2_lcd_sleep">接続中はカメラ画面OFF</string>
124126
125127 </resources>
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -111,4 +111,19 @@
111111 <item >RICOH_GR2</item>
112112 </string-array>
113113
114+ <string-array name="gr2_display_mode">
115+ <item >0</item>
116+ <item >1</item>
117+ <item >2</item>
118+ <item >3</item>
119+ </string-array>
120+
121+ <string-array name="gr2_display_mode_value">
122+ <item >0</item>
123+ <item >1</item>
124+ <item >2</item>
125+ <item >3</item>
126+ </string-array>
127+
128+
114129 </resources>
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -126,4 +126,7 @@
126126 <string name="camera_not_found">Not Found&#8230;</string>
127127 <string name="camera_received_reply">Received.</string>
128128 <string name="pref_connection_method">Connection Method</string>
129+ <string name="pref_gr2_display_mode">Display Mode</string>
130+ <string name="pref_gr2_lcd_sleep">Screen off during connected</string>
131+
129132 </resources>
--- a/app/src/main/res/xml/preferences_ricoh_gr2.xml
+++ b/app/src/main/res/xml/preferences_ricoh_gr2.xml
@@ -30,6 +30,17 @@
3030 android:title="@string/pref_cat_initialize">
3131
3232 <CheckBoxPreference
33+ android:key="gr2_lcd_sleep"
34+ android:title="@string/pref_gr2_lcd_sleep" />
35+
36+ <ListPreference
37+ android:title="@string/pref_gr2_display_mode"
38+ android:entryValues="@array/gr2_display_mode_value"
39+ android:entries="@array/gr2_display_mode"
40+ android:key="gr2_display_mode"
41+ android:defaultValue="0"/>
42+
43+ <CheckBoxPreference
3344 android:key="auto_connect_to_camera"
3445 android:title="@string/pref_auto_connect_camera"
3546 android:summary="@string/pref_summary_auto_connect_camera" />
Afficher sur ancien navigateur de dépôt.