Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
6bf700e7
Commit
6bf700e7
authored
Apr 22, 2019
by
Jeong Gilmo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#32917 芯温センサー
- 修正された詳細設計書について修正
parent
bbfc0958
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
132 additions
and
100 deletions
+132
-100
ABVJE_Res_Default_Android/res/values-ja/strings.xml
+4
-2
ABVJE_Res_Default_Android/res/values-ko/strings.xml
+4
-1
ABVJE_Res_Default_Android/res/values/strings.xml
+4
-1
ABVJE_UI_Android/res/layout/pairing_setting.xml
+19
-46
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
+16
-12
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
+36
-2
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/PairingSettingActivity.java
+49
-36
No files found.
ABVJE_Res_Default_Android/res/values-ja/strings.xml
View file @
6bf700e7
...
@@ -1378,10 +1378,12 @@
...
@@ -1378,10 +1378,12 @@
<string
name=
"thermometer"
>
芯温計
</string>
<string
name=
"thermometer"
>
芯温計
</string>
<string
name=
"ble_is_not_supported"
>
BLEを支援しません。
</string>
<string
name=
"ble_is_not_supported"
>
BLEを支援しません。
</string>
<string
name=
"bluetooth_is_not_supported"
>
ブルートゥースを支援しません。
</string>
<string
name=
"bluetooth_is_not_supported"
>
ブルートゥースを支援しません。
</string>
<string
name=
"bluetooth_is_not_working"
>
ブルートゥース
が機能しません
。
</string>
<string
name=
"bluetooth_is_not_working"
>
ブルートゥース
機能がオンになっているか確認してください
。
</string>
<string
name=
"msg_connected_bluetooth"
>
%sに接続されました。
</string>
<string
name=
"msg_connected_bluetooth"
>
%sに接続されました。
</string>
<string
name=
"msg_ble_not_connect"
>
接続が停止しました。
</string>
<string
name=
"msg_ble_not_connect"
>
接続が停止しました。
</string>
<string
name=
"msg_ble_connect_error"
>
%sと接続されていません。\n%sと接続状態を設定画面の機器連携から確認してください。
</string>
<string
name=
"msg_ble_connect_error"
>
%sと接続されていません。\n%sと接続状態を設定画面の機器連携から確認してください。
</string>
<string
name=
"msg_permission_dialog_bluetooth"
>
ブルートゥース利用権限が必要です。\nアプリ設定画面へ遷移します。
</string>
<string
name=
"msg_permission_dialog_bluetooth"
>
ブルートゥース利用権限が必要です。\nアプリ設定画面へ遷移します。
</string>
<string
name=
"msg_device_search"
>
ディバイスを検索中
</string>
<string
name=
"msg_device_connecting"
>
ディバイスと接続中
</string>
<string
name=
"msg_no_device_info"
>
登録された機器情報がありません。\n設定画面の機器連携から確認してください。
</string>
</resources>
</resources>
ABVJE_Res_Default_Android/res/values-ko/strings.xml
View file @
6bf700e7
...
@@ -1384,5 +1384,7 @@
...
@@ -1384,5 +1384,7 @@
<string
name=
"msg_ble_not_connect"
>
접속이 정지되었습니다.
</string>
<string
name=
"msg_ble_not_connect"
>
접속이 정지되었습니다.
</string>
<string
name=
"msg_ble_connect_error"
>
%s랑 접속되지않습니다.\n%s와의 접속상태를 설정화면의 기기연결에서 확인해주세요.
</string>
<string
name=
"msg_ble_connect_error"
>
%s랑 접속되지않습니다.\n%s와의 접속상태를 설정화면의 기기연결에서 확인해주세요.
</string>
<string
name=
"msg_permission_dialog_bluetooth"
>
블루투스이용권한이 필요합니다.\n설정화면으로 이동합니다.
</string>
<string
name=
"msg_permission_dialog_bluetooth"
>
블루투스이용권한이 필요합니다.\n설정화면으로 이동합니다.
</string>
<string
name=
"msg_device_search"
>
기기를 검색중\
</string>
<string
name=
"msg_device_connecting"
>
기기와 접속중
</string>
<string
name=
"msg_no_device_info"
>
등록된 기기정보가 없습니다.\n설정화면의 기기연결에서 확인해주세요.
</string>
</resources>
</resources>
\ No newline at end of file
ABVJE_Res_Default_Android/res/values/strings.xml
View file @
6bf700e7
...
@@ -1383,5 +1383,7 @@
...
@@ -1383,5 +1383,7 @@
<string
name=
"msg_ble_not_connect"
>
The connection has stopped.
</string>
<string
name=
"msg_ble_not_connect"
>
The connection has stopped.
</string>
<string
name=
"msg_ble_connect_error"
>
Not connected with% %s. \nCheck %s and connection status from the device linkage on the setting screen.
</string>
<string
name=
"msg_ble_connect_error"
>
Not connected with% %s. \nCheck %s and connection status from the device linkage on the setting screen.
</string>
<string
name=
"msg_permission_dialog_bluetooth"
>
You need Bluetooth access authority. \nIt changes to the application setting.
</string>
<string
name=
"msg_permission_dialog_bluetooth"
>
You need Bluetooth access authority. \nIt changes to the application setting.
</string>
<string
name=
"msg_device_search"
>
Searching Device
</string>
<string
name=
"msg_device_connecting"
>
Connecting Device
</string>
<string
name=
"msg_no_device_info"
>
There is no registered device information. \nPlease confirm from the device cooperation of the setting screen.
</string>
</resources>
</resources>
\ No newline at end of file
ABVJE_UI_Android/res/layout/pairing_setting.xml
View file @
6bf700e7
...
@@ -21,15 +21,14 @@
...
@@ -21,15 +21,14 @@
android:layout_height=
"50dp"
>
android:layout_height=
"50dp"
>
<TextView
<TextView
android:id=
"@+id/
tv
_toolbar_title"
android:id=
"@+id/
device
_toolbar_title"
style=
"@style/DialogToolBarTitle"
style=
"@style/DialogToolBarTitle"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerHorizontal=
"true"
android:layout_centerHorizontal=
"true"
android:layout_centerVertical=
"true"
android:layout_centerVertical=
"true"
android:text=
"@string/set_pairing"
android:textColor=
"@color/edt_text"
android:textColor=
"@color/edt_text"
android:textSize=
"
@dimen/opeartion_title_text_size
"
/>
android:textSize=
"
20sp
"
/>
<ImageButton
<ImageButton
android:id=
"@+id/close_btn"
android:id=
"@+id/close_btn"
...
@@ -40,6 +39,23 @@
...
@@ -40,6 +39,23 @@
android:background=
"@drawable/ic_operation_close"
android:background=
"@drawable/ic_operation_close"
android:onClick=
"onClickCloseView"
/>
android:onClick=
"onClickCloseView"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
>
<Button
android:id=
"@+id/btn_reload"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"5dp"
android:background=
"@drawable/ic_reload_list"
/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
<LinearLayout
...
@@ -51,49 +67,6 @@
...
@@ -51,49 +67,6 @@
android:layout_weight=
"1"
android:layout_weight=
"1"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<RelativeLayout
android:id=
"@+id/toolbar2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:minHeight=
"50dp"
android:visibility=
"visible"
>
<TextView
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"8dp"
android:gravity=
"left"
android:text=
"@string/thermometer"
android:textSize=
"20sp"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentEnd=
"true"
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
>
<Button
android:id=
"@+id/scan_button"
android:layout_width=
"50dp"
android:layout_height=
"50dp"
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"5dp"
android:text=
"@string/scan"
/>
<Button
android:id=
"@+id/stop_button"
android:layout_width=
"50dp"
android:layout_height=
"50dp"
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"5dp"
android:text=
"@string/stop"
/>
</LinearLayout>
</RelativeLayout>
<View
<View
android:layout_width=
"fill_parent"
android:layout_width=
"fill_parent"
android:layout_height=
"2dp"
android:layout_height=
"2dp"
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/cl/util/BleManagerUtil.java
View file @
6bf700e7
...
@@ -18,6 +18,8 @@ import android.bluetooth.BluetoothGattService;
...
@@ -18,6 +18,8 @@ import android.bluetooth.BluetoothGattService;
import
android.bluetooth.BluetoothManager
;
import
android.bluetooth.BluetoothManager
;
import
android.bluetooth.BluetoothProfile
;
import
android.bluetooth.BluetoothProfile
;
import
android.content.Context
;
import
android.content.Context
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
static
org
.
chromium
.
base
.
ThreadUtils
.
runOnUiThread
;
import
static
org
.
chromium
.
base
.
ThreadUtils
.
runOnUiThread
;
...
@@ -53,6 +55,7 @@ public class BleManagerUtil {
...
@@ -53,6 +55,7 @@ public class BleManagerUtil {
// 接続状態変更(connectGatt()の結果として呼ばれる。)
// 接続状態変更(connectGatt()の結果として呼ばれる。)
@Override
@Override
public
void
onConnectionStateChange
(
BluetoothGatt
gatt
,
int
status
,
int
newState
)
{
public
void
onConnectionStateChange
(
BluetoothGatt
gatt
,
int
status
,
int
newState
)
{
super
.
onConnectionStateChange
(
gatt
,
status
,
newState
);
// if( BluetoothGatt.GATT_SUCCESS != status ) {
// if( BluetoothGatt.GATT_SUCCESS != status ) {
// runOnUiThread( new Runnable() {
// runOnUiThread( new Runnable() {
// public void run() {
// public void run() {
...
@@ -61,6 +64,17 @@ public class BleManagerUtil {
...
@@ -61,6 +64,17 @@ public class BleManagerUtil {
// });
// });
// return;
// return;
// }
// }
Logger
.
d
(
"GATT_ message : [ "
+
status
);
// ディバイスと接続されていない場合のメッセージコード:133, 62
// ディバイスと接続が切れた場合のメッセージコード:19
if
(
status
==
133
||
status
==
62
)
{
// 接続失敗
runOnUiThread
(
new
Runnable
()
{
public
void
run
()
{
listener
.
onConnectionError
();
}
});
return
;
}
if
(
status
==
BluetoothGatt
.
GATT_SUCCESS
&&
BluetoothProfile
.
STATE_CONNECTED
==
newState
)
{
if
(
status
==
BluetoothGatt
.
GATT_SUCCESS
&&
BluetoothProfile
.
STATE_CONNECTED
==
newState
)
{
// 接続完了
// 接続完了
...
@@ -91,7 +105,6 @@ public class BleManagerUtil {
...
@@ -91,7 +105,6 @@ public class BleManagerUtil {
}
);
}
);
return
;
return
;
}
}
super
.
onConnectionStateChange
(
gatt
,
status
,
newState
);
}
}
// サービス検索が完了したときの処理(mBluetoothGatt.discoverServices()の結果として呼ばれる。)
// サービス検索が完了したときの処理(mBluetoothGatt.discoverServices()の結果として呼ばれる。)
...
@@ -195,6 +208,7 @@ public class BleManagerUtil {
...
@@ -195,6 +208,7 @@ public class BleManagerUtil {
void
onGetDeviceInfoFailed
();
// ディバイスと接続失敗時の情報渡す。
void
onGetDeviceInfoFailed
();
// ディバイスと接続失敗時の情報渡す。
void
onConnectionState
();
// ディバイスと接続された時情報渡す。
void
onConnectionState
();
// ディバイスと接続された時情報渡す。
void
onDisConnectionState
();
// ディバイスと切断時
void
onDisConnectionState
();
// ディバイスと切断時
void
onConnectionError
();
// ディバイス接続エラー
}
}
// 接続
// 接続
...
@@ -273,20 +287,10 @@ public class BleManagerUtil {
...
@@ -273,20 +287,10 @@ public class BleManagerUtil {
// Bluetoothアダプタの取得処理
// Bluetoothアダプタの取得処理
public
void
startDeviceInfo
()
{
public
void
startDeviceInfo
()
{
// disconnect();
// bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
// // Android端末がBLEをサポートしてるかの確認
// if( !context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_BLUETOOTH_LE ) ) {
// Toast.makeText( context, R.string.ble_is_not_supported, Toast.LENGTH_SHORT ).show();
// return;
// }
// Bluetoothアダプタの取得
// Bluetoothアダプタの取得
BluetoothManager
bluetoothManager
=
(
BluetoothManager
)
context
.
getSystemService
(
Context
.
BLUETOOTH_SERVICE
);
BluetoothManager
bluetoothManager
=
(
BluetoothManager
)
context
.
getSystemService
(
Context
.
BLUETOOTH_SERVICE
);
mBluetoothAdapter
=
bluetoothManager
.
getAdapter
();
mBluetoothAdapter
=
bluetoothManager
.
getAdapter
();
if
(
null
==
mBluetoothAdapter
)
if
(
null
==
mBluetoothAdapter
)
{
// Android端末がBluetoothをサポートしていない
{
// Android端末がBluetoothをサポートしていない
Toast
.
makeText
(
context
,
R
.
string
.
bluetooth_is_not_supported
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
context
,
R
.
string
.
bluetooth_is_not_supported
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
return
;
}
}
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/common/activity/ABVContentViewActivity.java
View file @
6bf700e7
...
@@ -239,7 +239,23 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
...
@@ -239,7 +239,23 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// get Device info
// get Device info
bleManagerUtil
=
new
BleManagerUtil
(
this
,
new
BleManagerUtil
.
BleManagerUtilListener
()
{
bleManagerUtil
=
new
BleManagerUtil
(
this
,
new
BleManagerUtil
.
BleManagerUtilListener
()
{
@Override
@Override
public
void
onConnectionError
()
{
Logger
.
d
(
TAG
,
"onDisConnectionState"
);
putUserPref
(
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED
,
0
);
ABookAlertDialog
alert
=
AlertDialogUtil
.
createAlertDialog
(
ABVContentViewActivity
.
this
,
R
.
string
.
thermometer
);
alert
.
setMessage
(
String
.
format
(
getString
(
R
.
string
.
msg_ble_connect_error
),
getString
(
R
.
string
.
thermometer
),
getString
(
R
.
string
.
thermometer
)));
alert
.
setButton
(
DialogInterface
.
BUTTON_POSITIVE
,
getString
(
R
.
string
.
ok
),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
setThermometerData
(
""
);
}
});
alert
.
show
();
}
@Override
public
void
onConnectionState
()
{
// 接続
public
void
onConnectionState
()
{
// 接続
Logger
.
d
(
TAG
,
"onDisConnectionState"
);
putUserPref
(
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED
,
1
);
putUserPref
(
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED
,
1
);
ABVToastUtil
.
showMakeText
(
getApplicationContext
(),
ABVToastUtil
.
showMakeText
(
getApplicationContext
(),
String
.
format
(
getString
(
R
.
string
.
msg_connected_bluetooth
),
getString
(
R
.
string
.
thermometer
)),
String
.
format
(
getString
(
R
.
string
.
msg_connected_bluetooth
),
getString
(
R
.
string
.
thermometer
)),
...
@@ -248,12 +264,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
...
@@ -248,12 +264,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
@Override
public
void
onDisConnectionState
()
{
// 切断
public
void
onDisConnectionState
()
{
// 切断
Logger
.
d
(
TAG
,
"onDisConnectionState"
);
putUserPref
(
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED
,
0
);
putUserPref
(
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED
,
0
);
ABVToastUtil
.
showMakeText
(
getApplicationContext
(),
getString
(
R
.
string
.
msg_ble_not_connect
),
Toast
.
LENGTH_SHORT
);
ABVToastUtil
.
showMakeText
(
getApplicationContext
(),
getString
(
R
.
string
.
msg_ble_not_connect
),
Toast
.
LENGTH_SHORT
);
}
}
@Override
@Override
public
void
onGetDeviceInfo
(
String
strTemp
)
{
// 機器のデータ
public
void
onGetDeviceInfo
(
String
strTemp
)
{
// 機器のデータ
Logger
.
d
(
TAG
,
"onDisConnectionState"
);
Toast
.
makeText
(
getApplicationContext
(),
strTemp
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
strTemp
,
Toast
.
LENGTH_SHORT
).
show
();
Logger
.
d
(
TAG
,
"get temperature [%s]"
,
strTemp
);
Logger
.
d
(
TAG
,
"get temperature [%s]"
,
strTemp
);
setThermometerData
(
strTemp
);
setThermometerData
(
strTemp
);
...
@@ -261,10 +279,16 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
...
@@ -261,10 +279,16 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
@Override
public
void
onGetDeviceInfoFailed
()
{
// 機器のエラー
public
void
onGetDeviceInfoFailed
()
{
// 機器のエラー
Logger
.
d
(
TAG
,
"onDisConnectionState"
);
putUserPref
(
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED
,
0
);
putUserPref
(
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED
,
0
);
ABookAlertDialog
alert
=
AlertDialogUtil
.
createAlertDialog
(
ABVContentViewActivity
.
this
,
R
.
string
.
thermometer
);
ABookAlertDialog
alert
=
AlertDialogUtil
.
createAlertDialog
(
ABVContentViewActivity
.
this
,
R
.
string
.
thermometer
);
alert
.
setMessage
(
String
.
format
(
getString
(
R
.
string
.
msg_ble_connect_error
),
getString
(
R
.
string
.
thermometer
),
getString
(
R
.
string
.
thermometer
)));
alert
.
setMessage
(
String
.
format
(
getString
(
R
.
string
.
msg_ble_connect_error
),
getString
(
R
.
string
.
thermometer
),
getString
(
R
.
string
.
thermometer
)));
alert
.
setButton
(
DialogInterface
.
BUTTON_POSITIVE
,
getString
(
R
.
string
.
ok
),
(
DialogInterface
.
OnClickListener
)
null
);
alert
.
setButton
(
DialogInterface
.
BUTTON_POSITIVE
,
getString
(
R
.
string
.
ok
),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
setThermometerData
(
""
);
}
});
alert
.
show
();
alert
.
show
();
}
}
});
});
...
@@ -1440,7 +1464,17 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
...
@@ -1440,7 +1464,17 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// 接続
// 接続
bleManagerUtil
.
connect
();
bleManagerUtil
.
connect
();
}
else
{
}
else
{
setPairingSetting
();
// 接続するのために機器設定画面に遷移する。
// 設定画面に遷移すること
// setPairingSetting(); // 接続するのために機器設定画面に遷移する。
// ディバイス情報がない場合
ABookAlertDialog
alert
=
AlertDialogUtil
.
createAlertDialog
(
ABVContentViewActivity
.
this
,
R
.
string
.
thermometer
);
alert
.
setMessage
(
getString
(
R
.
string
.
msg_no_device_info
));
alert
.
setButton
(
DialogInterface
.
BUTTON_POSITIVE
,
getString
(
R
.
string
.
ok
),
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
setThermometerData
(
""
);
}
});
}
}
}
else
{
}
else
{
Logger
.
w
(
TAG
,
"onGetDeviceInfoFailed Connect BLE Device false"
);
Logger
.
w
(
TAG
,
"onGetDeviceInfoFailed Connect BLE Device false"
);
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/PairingSettingActivity.java
View file @
6bf700e7
...
@@ -74,15 +74,16 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -74,15 +74,16 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
@Override
@Override
public
void
run
()
{
public
void
run
()
{
BluetoothDevice
device
=
result
.
getDevice
();
BluetoothDevice
device
=
result
.
getDevice
();
// if(device.getName() != null && device.getName().startsWith("MF500B")) {
// 識別商品名に絞る
if
(
device
.
getName
()
!=
null
&&
device
.
getName
().
startsWith
(
"MF500"
))
{
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
EXTRAS_DEVICE_NAME
,
device
.
getName
());
map
.
put
(
EXTRAS_DEVICE_NAME
,
device
.
getName
());
map
.
put
(
EXTRAS_DEVICE_ADDRESS
,
device
.
getAddress
());
map
.
put
(
EXTRAS_DEVICE_ADDRESS
,
device
.
getAddress
());
map
.
put
(
DEVICE_CONNECTED
,
"0"
);
map
.
put
(
DEVICE_CONNECTED
,
"0"
);
if
(
device
.
getName
()
!=
null
)
{
if
(
device
.
getName
()
!=
null
)
{
mBleListAdapter
.
addDevice
(
map
);
mBleListAdapter
.
addDevice
(
map
);
}
}
}
}
}
}
);
}
);
...
@@ -101,6 +102,9 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -101,6 +102,9 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
pairing_setting
);
setContentView
(
R
.
layout
.
pairing_setting
);
TextView
deviceTitle
=
(
TextView
)
findViewById
(
R
.
id
.
device_toolbar_title
);
deviceTitle
.
setText
(
R
.
string
.
thermometer
);
// 戻り値の初期化
// 戻り値の初期化
setResult
(
Activity
.
RESULT_CANCELED
);
setResult
(
Activity
.
RESULT_CANCELED
);
...
@@ -144,7 +148,15 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -144,7 +148,15 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
// Bluetoothと接続処理する
// Bluetoothと接続処理する
bleManagerUtil
=
new
BleManagerUtil
(
this
,
new
BleManagerUtil
.
BleManagerUtilListener
()
{
bleManagerUtil
=
new
BleManagerUtil
(
this
,
new
BleManagerUtil
.
BleManagerUtilListener
()
{
@Override
@Override
public
void
onConnectionError
()
{
Logger
.
d
(
TAG
,
"onConnectionError"
);
closeProgressPopup
();
}
@Override
public
void
onConnectionState
()
{
// 接続
public
void
onConnectionState
()
{
// 接続
Logger
.
d
(
TAG
,
"onConnectionState"
);
closeProgressPopup
();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
EXTRAS_DEVICE_NAME
,
bleManagerUtil
.
mDeviceName
);
map
.
put
(
EXTRAS_DEVICE_NAME
,
bleManagerUtil
.
mDeviceName
);
map
.
put
(
EXTRAS_DEVICE_ADDRESS
,
bleManagerUtil
.
mDeviceAddress
);
map
.
put
(
EXTRAS_DEVICE_ADDRESS
,
bleManagerUtil
.
mDeviceAddress
);
...
@@ -159,6 +171,8 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -159,6 +171,8 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
@Override
@Override
public
void
onDisConnectionState
()
{
// 切断
public
void
onDisConnectionState
()
{
// 切断
Logger
.
d
(
TAG
,
"onDisConnectionState"
);
closeProgressPopup
();
// mDeviceListAdapter.notifyDataSetChanged();
// mDeviceListAdapter.notifyDataSetChanged();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
map
.
put
(
EXTRAS_DEVICE_NAME
,
bleManagerUtil
.
mDeviceName
);
map
.
put
(
EXTRAS_DEVICE_NAME
,
bleManagerUtil
.
mDeviceName
);
...
@@ -176,20 +190,23 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -176,20 +190,23 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
@Override
@Override
public
void
onGetDeviceInfo
(
String
strTemp
)
{
// 機器のデータ
public
void
onGetDeviceInfo
(
String
strTemp
)
{
// 機器のデータ
Logger
.
d
(
TAG
,
"onGetDeviceInfo"
);
closeProgressPopup
();
// Toast.makeText( getApplicationContext(), R.string.msg_connected_bluetooth, Toast.LENGTH_SHORT ).show();
// Toast.makeText( getApplicationContext(), R.string.msg_connected_bluetooth, Toast.LENGTH_SHORT ).show();
Logger
.
d
(
TAG
,
"get temperature [%s]"
,
strTemp
);
Logger
.
d
(
TAG
,
"get temperature [%s]"
,
strTemp
);
}
}
@Override
@Override
public
void
onGetDeviceInfoFailed
()
{
// 機器のエラー
public
void
onGetDeviceInfoFailed
()
{
// 機器のエラー
Logger
.
d
(
TAG
,
"onGetDeviceInfoFailed"
);
closeProgressPopup
();
showConfirmAlert
(
R
.
string
.
thermometer
,
String
.
format
(
getString
(
R
.
string
.
msg_ble_connect_error
),
getString
(
R
.
string
.
thermometer
),
getString
(
R
.
string
.
thermometer
)));
showConfirmAlert
(
R
.
string
.
thermometer
,
String
.
format
(
getString
(
R
.
string
.
msg_ble_connect_error
),
getString
(
R
.
string
.
thermometer
),
getString
(
R
.
string
.
thermometer
)));
}
}
});
});
bleManagerUtil
.
startDeviceInfo
();
bleManagerUtil
.
startDeviceInfo
();
//
Scan
Button
//
Reload
Button
mButton_Scan
=
(
Button
)
findViewById
(
R
.
id
.
scan_button
);
mButton_Scan
=
(
Button
)
findViewById
(
R
.
id
.
btn_reload
);
mButton_Scan
.
setAllCaps
(
false
);
mButton_Scan
.
setAllCaps
(
false
);
mButton_Scan
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
mButton_Scan
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
...
@@ -198,19 +215,6 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -198,19 +215,6 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
}
}
});
});
// Stop Button
mButton_Stop
=
(
Button
)
findViewById
(
R
.
id
.
stop_button
);
mButton_Stop
.
setAllCaps
(
false
);
mButton_Stop
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
stopScan
();
}
});
// 設定画面が表示する場合、スキャンボタンが見えないように
mButton_Stop
.
setVisibility
(
View
.
GONE
);
// 保存されているディバイスの情報がある場合、リストに表示する。
// 保存されているディバイスの情報がある場合、リストに表示する。
if
(
getUserPref
(
AppDefType
.
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS
,
""
).
length
()
>
0
)
{
if
(
getUserPref
(
AppDefType
.
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS
,
""
).
length
()
>
0
)
{
Map
<
String
,
String
>
getUserDataMap
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
getUserDataMap
=
new
HashMap
<
String
,
String
>();
...
@@ -233,8 +237,11 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -233,8 +237,11 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
// デバイスのBluetooth機能の有効化要求
// デバイスのBluetooth機能の有効化要求
requestBluetoothFeature
();
requestBluetoothFeature
();
// スキャン開始
// ローカルに保存されているディバイスの情報がない場合処理を行う
startScan
();
if
(
getUserPref
(
AppDefType
.
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS
,
""
).
length
()
==
0
)
{
// スキャン開始
startScan
();
}
}
}
// 別のアクティビティ(か別のアプリ)に移行したことで、バックグラウンドに追いやられた時
// 別のアクティビティ(か別のアプリ)に移行したことで、バックグラウンドに追いやられた時
...
@@ -296,6 +303,7 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -296,6 +303,7 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
return
;
return
;
}
}
showProgressPopup
(
getRString
(
R
.
string
.
msg_device_search
));
// スキャン開始(一定時間後にスキャン停止する)
// スキャン開始(一定時間後にスキャン停止する)
mHandler
.
postDelayed
(
new
Runnable
()
{
mHandler
.
postDelayed
(
new
Runnable
()
{
@Override
@Override
...
@@ -303,19 +311,14 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -303,19 +311,14 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
mScanning
=
false
;
mScanning
=
false
;
scanner
.
stopScan
(
mLeScanCallback
);
scanner
.
stopScan
(
mLeScanCallback
);
// ボタンの更新
mButton_Scan
.
setVisibility
(
View
.
VISIBLE
);
mButton_Stop
.
setVisibility
(
View
.
GONE
);
Logger
.
d
(
TAG
,
"scan in 10 sec"
);
Logger
.
d
(
TAG
,
"scan in 10 sec"
);
closeProgressPopup
();
}
}
},
SCAN_PERIOD
);
},
SCAN_PERIOD
);
mScanning
=
true
;
mScanning
=
true
;
scanner
.
startScan
(
mLeScanCallback
);
scanner
.
startScan
(
mLeScanCallback
);
// ボタンの更新
mButton_Scan
.
setVisibility
(
View
.
GONE
);
mButton_Stop
.
setVisibility
(
View
.
VISIBLE
);
Logger
.
d
(
TAG
,
"start scan !!"
);
Logger
.
d
(
TAG
,
"start scan !!"
);
}
}
...
@@ -333,9 +336,6 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -333,9 +336,6 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
mScanning
=
false
;
mScanning
=
false
;
scanner
.
stopScan
(
mLeScanCallback
);
scanner
.
stopScan
(
mLeScanCallback
);
// ボタンの更新
mButton_Scan
.
setVisibility
(
View
.
VISIBLE
);
mButton_Stop
.
setVisibility
(
View
.
GONE
);
Logger
.
d
(
TAG
,
"stop scan !!"
);
Logger
.
d
(
TAG
,
"stop scan !!"
);
}
}
...
@@ -372,10 +372,23 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
...
@@ -372,10 +372,23 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
}
else
{
}
else
{
bleManagerUtil
.
mDeviceAddress
=
deviceAddress
;
bleManagerUtil
.
mDeviceAddress
=
deviceAddress
;
bleManagerUtil
.
mDeviceName
=
deviceName
;
bleManagerUtil
.
mDeviceName
=
deviceName
;
showProgressPopup
(
getString
(
R
.
string
.
msg_device_connecting
));
// デバイスのBluetooth機能の有効化要求
requestBluetoothFeature
();
// 接続
bleManagerUtil
.
connect
();
bleManagerUtil
.
connect
();
}
}
}
}
protected
boolean
testcheck
()
{
if
(
getUserPref
(
AppDefType
.
UserPrefKey
.
BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED
,
0
)
==
1
)
{
return
true
;
}
return
false
;
}
// 閉じるボタンの処理
// 閉じるボタンの処理
public
void
onClickCloseView
(
View
v
)
{
public
void
onClickCloseView
(
View
v
)
{
finish
();
finish
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment