applicationId "net.osdn.gokigen.a01d"
minSdkVersion 14
targetSdkVersion 27
- versionCode 10003
- versionName "1.0.3"
+ versionCode 10004
+ versionName "1.0.4"
}
buildTypes {
release {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:27.0.0'
+ compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
- compile 'com.android.support:preference-v14:27.0.0'
- //provided 'com.google.android.things:androidthings:0.4.1-devpreview'
- compile 'com.android.support:preference-v7:27.0.0'
- compile 'com.android.support:exifinterface:27.0.0'
+ compile 'com.android.support:preference-v14:27.0.2'
+ compile 'com.android.support:preference-v7:27.0.2'
+ compile 'com.android.support:exifinterface:27.0.2'
compile files('libs/olycamerakit.jar')
}
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.BLUETOOTH" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:allowBackup="true"
import android.Manifest;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
+import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.OlympusInterfaceProvider;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ICameraStatusReceiver;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.PowerOnCamera;
import net.osdn.gokigen.a01d.liveview.IStatusViewDrawer;
import net.osdn.gokigen.a01d.liveview.LiveViewFragment;
import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
* A01d ;
*
*/
-public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver, IChangeScene
+public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver, IChangeScene, PowerOnCamera.PowerOnCameraCallback
{
private final String TAG = toString();
private IOlympusInterfaceProvider interfaceProvider = null;
if ((ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED) ||
+ (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) ||
+ (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) != PackageManager.PERMISSION_GRANTED) ||
+ (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED)) {
ActivityCompat.requestPermissions(this,
new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_NETWORK_STATE,
Manifest.permission.ACCESS_WIFI_STATE,
+ Manifest.permission.BLUETOOTH,
+ Manifest.permission.BLUETOOTH_ADMIN,
+ Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.INTERNET,
},
REQUEST_NEED_PERMISSIONS);
*
*/
@Override
- public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults)
+ public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults)
{
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
onReadyClass();
OlympusInterfaceProvider provider = new OlympusInterfaceProvider(this, this);
interfaceProvider = provider;
interfaceInjector = provider;
- } catch (Exception e)
+ }
+ catch (Exception e)
{
e.printStackTrace();
}
*/
private void onReadyClass()
{
- // 自動接続の指示があったとき
- if (isAutoConnectCamera())
+ if (isBlePowerOn())
{
+ // BLEでカメラの電源をONにする設定だった時
+ try
+ {
+ // カメラの電源ONクラスを呼び出しておく
+ PowerOnCamera powerOnCamera = new PowerOnCamera(this);
+ powerOnCamera.wakeup();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ else if (isAutoConnectCamera())
+ {
+ // 自動接続の指示があったとき
changeCameraConnection();
}
}
*
*/
@Override
- protected void onPause() {
+ protected void onPause()
+ {
super.onPause();
- try {
+ try
+ {
IOlyCameraConnection connection = interfaceProvider.getOlyCameraConnection();
- if (connection != null) {
+ if (connection != null)
+ {
connection.stopWatchWifiStatus(this);
}
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
e.printStackTrace();
}
}
public void changeSceneToCameraPropertyList()
{
IOlyCameraConnection connection = interfaceProvider.getOlyCameraConnection();
- if (connection != null) {
+ if (connection != null)
+ {
IOlyCameraConnection.CameraConnectionStatus status = connection.getConnectionStatus();
- if (status == IOlyCameraConnection.CameraConnectionStatus.CONNECTED) {
- if (propertyListFragment == null) {
+ if (status == IOlyCameraConnection.CameraConnectionStatus.CONNECTED)
+ {
+ if (propertyListFragment == null)
+ {
propertyListFragment = new OlyCameraPropertyListFragment();
}
propertyListFragment.setInterface(this, interfaceProvider.getCameraPropertyProvider());
}
/**
- * 設定画面を開く
+ * 設定画面を開く
+ *
*/
@Override
public void changeSceneToConfiguration()
}
/**
- * カメラとの接続・切断のシーケンス
+ * カメラとの接続・切断のシーケンス
*/
@Override
public void changeCameraConnection()
}
IOlyCameraConnection connection = interfaceProvider.getOlyCameraConnection();
- if (connection != null) {
+ if (connection != null)
+ {
IOlyCameraConnection.CameraConnectionStatus status = connection.getConnectionStatus();
if (status == IOlyCameraConnection.CameraConnectionStatus.CONNECTED)
{
* アプリを抜ける
*/
@Override
- public void exitApplication() {
+ public void exitApplication()
+ {
Log.v(TAG, "exitApplication()");
- try {
+ try
+ {
IOlyCameraConnection connection = interfaceProvider.getOlyCameraConnection();
- if (connection != null) {
+ if (connection != null)
+ {
connection.disconnect(true);
}
finish();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
e.printStackTrace();
}
}
*
*/
@Override
- public void onStatusNotify(String message) {
+ public void onStatusNotify(String message)
+ {
Log.v(TAG, " CONNECTION MESSAGE : " + message);
- if (statusViewDrawer != null) {
+ if (statusViewDrawer != null)
+ {
statusViewDrawer.updateStatusView(message);
IOlyCameraConnection connection = interfaceProvider.getOlyCameraConnection();
- if (connection != null) {
+ if (connection != null)
+ {
statusViewDrawer.updateConnectionStatus(connection.getConnectionStatus());
}
}
}
-
/**
*
*
}
}
+ /**
+ * BLE経由でカメラの電源を入れるかどうか
+ *
+ */
+ private boolean isBlePowerOn()
+ {
+ boolean ret = false;
+ try
+ {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
+ ret = preferences.getBoolean(IPreferencePropertyAccessor.BLE_POWER_ON, false);
+ // Log.v(TAG, "isBlePowerOn() : " + ret);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (ret);
+ }
+
+ /**
+ * カメラへの自動接続を行うかどうか
+ *
+ */
private boolean isAutoConnectCamera()
{
boolean ret = true;
}
return (ret);
}
+
+ /**
+ * カメラへのBLE接続指示が完了したとき
+ *
+ * @param isExecuted true : BLEで起動した, false : 起動していない、その他
+ */
+ @Override
+ public void wakeupExecuted(boolean isExecuted)
+ {
+ Log.v(TAG, "wakeupExecuted() : " + isExecuted);
+ if ((isExecuted)&&(isAutoConnectCamera()))
+ {
+ // カメラへ自動接続する設定だった場合、カメラへWiFi接続する
+ changeCameraConnection();
+ }
+ }
}
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble;
+
+
+import android.util.Log;
+
+/**
+ * BLE経由でカメラの電源を入れるクラス
+ *
+ */
+public class PowerOnCamera
+{
+ private final String TAG = toString();
+ private final PowerOnCameraCallback callback;
+
+ public PowerOnCamera(PowerOnCameraCallback callback)
+ {
+ Log.v(TAG, "PowerOnCamera()");
+
+ this.callback = callback;
+ }
+
+ public void wakeup()
+ {
+ Log.v(TAG, "PowerOnCamera::wakeup()");
+
+
+ // 今は暫定で返しちゃう
+ callback.wakeupExecuted(true);
+ }
+
+ /**
+ * 実行終了時のコールバックのインタフェース
+ *
+ */
+ public interface PowerOnCameraCallback
+ {
+ void wakeupExecuted(boolean isExecute);
+ }
+
+}
String EXIT_APPLICATION = "exit_application";
String AUTO_CONNECT_TO_CAMERA = "auto_connect_to_camera";
+ String BLE_POWER_ON = "ble_power_on";
String TAKE_MODE = "take_mode";
String TAKE_MODE_DEFAULT_VALUE = "P";
String CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW = "capture_both_camera_and_live_view";
-
-/*****
+/*
int CHOICE_SPLASH_SCREEN = 10;
int SELECT_SAMPLE_IMAGE_CODE = 110;
{
editor.putBoolean(net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.RAW, true);
}
+ if (!items.containsKey(IPreferencePropertyAccessor.BLE_POWER_ON))
+ {
+ editor.putBoolean(net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.BLE_POWER_ON, false);
+ }
if (!items.containsKey(net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA))
{
editor.putBoolean(net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
setCameraProperty(IOlyCameraProperty.RAW, propertyValue);
break;
+ case IPreferencePropertyAccessor.BLE_POWER_ON:
+ value = preferences.getBoolean(key, false);
+ Log.v(TAG, " " + key + " , " + value);
+ break;
+
case IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA:
value = preferences.getBoolean(key, true);
Log.v(TAG, " " + key + " , " + value);
setListPreference(IPreferencePropertyAccessor.TAKE_MODE, IPreferencePropertyAccessor.TAKE_MODE, net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.TAKE_MODE_DEFAULT_VALUE);
setListPreference(IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL, IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL, net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL_DEFAULT_VALUE);
setBooleanPreference(IPreferencePropertyAccessor.RAW, IPreferencePropertyAccessor.RAW, true);
+ setBooleanPreference(IPreferencePropertyAccessor.BLE_POWER_ON, IPreferencePropertyAccessor.BLE_POWER_ON, false);
+ setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
// カメラキットのバージョン
findPreference(IPreferencePropertyAccessor.CAMERAKIT_VERSION).setSummary(OLYCamera.getVersion());
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
+ android:focusable="true"
android:contentDescription="@string/favorite"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:clickable="true"
+ android:focusable="true"
android:contentDescription="@string/button"
android:layout_marginBottom="2pt"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:clickable="true"
+ android:focusable="true"
android:contentDescription="@string/button"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
+ android:focusable="true"
android:layout_above="@id/focusing_button"
android:layout_alignLeft="@id/focusing_button"
android:layout_alignStart="@id/focusing_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignParentLeft="true"
android:layout_toRightOf="@id/connect_disconnect_button"
android:layout_toEndOf="@id/connect_disconnect_button"
android:clickable="true"
+ android:focusable="true"
android:gravity="start|center"
android:text="@string/information"
android:textColor="@color/background_translucent_dark"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignTop="@id/show_preference_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignTop="@id/show_preference_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignTop="@id/show_preference_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
+ android:focusable="true"
android:contentDescription="@string/favorite"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitEnd"
android:contentDescription="@string/button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:contentDescription="@string/button"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:clickable="true"
+ android:focusable="true"
android:text="@string/live_view_scale_default"
android:contentDescription="@string/button"
android:visibility="visible"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignParentRight="true"
android:src="@drawable/ic_settings_black_24dp"
android:visibility="visible" />
-
-
<ImageButton
android:id="@+id/connect_disconnect_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignParentLeft="true"
android:layout_toRightOf="@id/connect_disconnect_button"
android:layout_toEndOf="@id/connect_disconnect_button"
android:clickable="true"
+ android:focusable="true"
android:gravity="start|center"
android:text="@string/information"
android:textColor="@color/background_translucent_dark"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignTop="@id/show_preference_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignTop="@id/show_preference_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clickable="true"
+ android:focusable="true"
android:gravity="center"
android:scaleType="fitCenter"
android:layout_alignTop="@id/show_preference_button"
<string name="pref_auto_connect_camera">カメラに自動接続</string>
<string name="pref_summary_auto_connect_camera">通常、チェックを入れたままご使用ください</string>
<string name="dialog_message_power_off">カメラの電源を切り、アプリケーションを終了します。</string>
+ <string name="pref_bluetooth_power_on">BLEでカメラ電源ON</string>
+ <string name="pref_summary_bluetooth_power_on">起動時、BLEでカメラをONにします。</string>
<string name="pref_cat_live_view">ライブビュー設定</string>
<string name="pref_live_view_quality">ライブビュー品質</string>
<string name="pref_camera_version">Camera Version</string>
<string name="pref_camerakit_version">Camera kit Version</string>
- <string name="pref_cat_gokigen">GOKIGEN Project(現在、直接開けません)</string>
+ <string name="pref_cat_gokigen">GOKIGEN Project</string>
<string name="pref_instruction_manual">操作説明</string>
<string name="pref_privacy_policy">プライバシーポリシー</string>
<string name="pref_auto_connect_camera">Auto Connect To Camera</string>
<string name="pref_summary_auto_connect_camera">Normally to keep ON.</string>
<string name="dialog_message_power_off">Power Off</string>
+ <string name="pref_bluetooth_power_on">BLE Power On</string>
+ <string name="pref_summary_bluetooth_power_on">Camera Power on via BLE</string>
<string name="pref_cat_live_view">Live View Settings</string>
<string name="pref_live_view_quality">Live View Quality</string>
<string name="pref_camera_version">Camera Version</string>
<string name="pref_camerakit_version">Camera kit Version</string>
- <string name="pref_cat_gokigen">GOKIGEN(Currently not open directly)</string>
+ <string name="pref_cat_gokigen">GOKIGEN</string>
<string name="pref_instruction_manual">A01d Instructions</string>
<string name="pref_privacy_policy">Privacy Policy</string>
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" />
+ android:key="auto_connect_to_camera"
+ android:title="@string/pref_auto_connect_camera"
+ android:summary="@string/pref_summary_auto_connect_camera" />
+
+ <CheckBoxPreference
+ android:key="ble_power_on"
+ android:title="@string/pref_bluetooth_power_on"
+ android:summary="@string/pref_summary_bluetooth_power_on" />
+
</PreferenceCategory>
<PreferenceCategory
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.0'
+ classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files