Commit 21f807f5 by Lee Jaebin

#36104 機器連携(SPP通信処理)対応

parent 55aeeca4
...@@ -112,10 +112,6 @@ ...@@ -112,10 +112,6 @@
<option name="m_ignoreInvisibleFields" value="true" /> <option name="m_ignoreInvisibleFields" value="true" />
<option name="m_ignoreStaticMethods" value="true" /> <option name="m_ignoreStaticMethods" value="true" />
</inspection_tool> </inspection_tool>
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
</inspection_tool>
<inspection_tool class="MagicConstant" enabled="true" level="ERROR" enabled_by_default="true" /> <inspection_tool class="MagicConstant" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="MagicNumber" enabled="true" level="INFO" enabled_by_default="true"> <inspection_tool class="MagicNumber" enabled="true" level="INFO" enabled_by_default="true">
<option name="ignoreInitialCapacity" value="true" /> <option name="ignoreInitialCapacity" value="true" />
...@@ -138,6 +134,9 @@ ...@@ -138,6 +134,9 @@
<option name="updateNames"> <option name="updateNames">
<value /> <value />
</option> </option>
<option name="ignoredClasses">
<value />
</option>
</inspection_tool> </inspection_tool>
<inspection_tool class="MismatchedStringBuilderQueryUpdate" enabled="true" level="ERROR" enabled_by_default="true" /> <inspection_tool class="MismatchedStringBuilderQueryUpdate" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="MissingOverrideAnnotation" enabled="true" level="ERROR" enabled_by_default="true"> <inspection_tool class="MissingOverrideAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
...@@ -260,7 +259,7 @@ ...@@ -260,7 +259,7 @@
<option name="REPORT_REDUNDANT_INITIALIZER" value="true" /> <option name="REPORT_REDUNDANT_INITIALIZER" value="true" />
</inspection_tool> </inspection_tool>
<inspection_tool class="UseOfPropertiesAsHashtable" enabled="true" level="ERROR" enabled_by_default="true" /> <inspection_tool class="UseOfPropertiesAsHashtable" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="VariableNotUsedInsideIf" enabled="true" level="ERROR" enabled_by_default="true" /> <inspection_tool class="VariableNotUsedInsideIf" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="unused" enabled="true" level="TODO" enabled_by_default="true"> <inspection_tool class="unused" enabled="true" level="TODO" enabled_by_default="true">
<option name="LOCAL_VARIABLE" value="true" /> <option name="LOCAL_VARIABLE" value="true" />
<option name="FIELD" value="true" /> <option name="FIELD" value="true" />
......
package jp.agentec.abook.abv.bl.acms.client.json; package jp.agentec.abook.abv.bl.acms.client.json;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient; import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.common.exception.AcmsException; import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException; import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.common.util.JsonUtil; import jp.agentec.abook.abv.bl.common.util.JsonUtil;
import jp.agentec.abook.abv.bl.dto.ContentDto; import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.SppDeviceDto;
import org.json.adf.JSONArray; import org.json.adf.JSONArray;
import org.json.adf.JSONObject; import org.json.adf.JSONObject;
...@@ -25,9 +27,20 @@ public class ContentVersionsJSON extends AcmsCommonJSON { ...@@ -25,9 +27,20 @@ public class ContentVersionsJSON extends AcmsCommonJSON {
public static final String ContentType = "contentType"; public static final String ContentType = "contentType";
public static final String FetchDate = "fetchDate"; public static final String FetchDate = "fetchDate";
// SPP通信の端末情報リスト
public static final String SppDeviceInfoList = "sppDeviceInfoList";
public static final String SppDeviceId = "sppDeviceId";
public static final String SppDeviceName = "sppDeviceName";
public static final String DataStartIndex = "dataStartIndex";
public static final String DataEndIndex = "dataEndIndex";
public ArrayList<ContentDto> contentVersions; public ArrayList<ContentDto> contentVersions;
public String fetchDate; public String fetchDate;
// SPP通信機器のDTOリスト
public List<SppDeviceDto> sppDeviceDtoList;
public static final String ResourcePatternType = "resourcePatternType"; // 文言リソースパターン public static final String ResourcePatternType = "resourcePatternType"; // 文言リソースパターン
public int resourcePatternType; // 文言リソースパターン変数 public int resourcePatternType; // 文言リソースパターン変数
...@@ -44,6 +57,26 @@ public class ContentVersionsJSON extends AcmsCommonJSON { ...@@ -44,6 +57,26 @@ public class ContentVersionsJSON extends AcmsCommonJSON {
if (json.has(FetchDate)) { if (json.has(FetchDate)) {
fetchDate = json.getString(FetchDate); fetchDate = json.getString(FetchDate);
} }
// SppDeviceInfoListキーが存在する場合、sppDeviceDtoListにセットする
if (json.has(SppDeviceInfoList)) {
sppDeviceDtoList = new ArrayList<SppDeviceDto>();
JSONArray sppDeviceInfoArray = json.getJSONArray(SppDeviceInfoList);
for (int j = 0; j < sppDeviceInfoArray.length(); j++) {
JSONObject sppDeviceJson = sppDeviceInfoArray.getJSONObject(j);
SppDeviceDto sppDeviceDto = new SppDeviceDto();
// SPP通信機器ID
sppDeviceDto.sppDeviceId = getInt(sppDeviceJson, SppDeviceId);
// SPP通信機器名
sppDeviceDto.sppDeviceName = getString(sppDeviceJson, SppDeviceName);
// SPP通信機器から取得対象の開始文字列
sppDeviceDto.dataStartIndex = getInt(sppDeviceJson, DataStartIndex);
// SPP通信機器から取得対象の終了文字列
sppDeviceDto.dataEndIndex = getInt(sppDeviceJson, DataEndIndex);
sppDeviceDtoList.add(sppDeviceDto);
}
}
if (json.has(ContentList)) { if (json.has(ContentList)) {
JSONArray jarr = json.getJSONArray(ContentList); JSONArray jarr = json.getJSONArray(ContentList);
......
...@@ -171,8 +171,11 @@ public class Constant { ...@@ -171,8 +171,11 @@ public class Constant {
// 連携機器の区分 // 連携機器の区分
public interface DeviceType { public interface DeviceType {
int thermomete = 1; // 中心温度計 int centerThermomete = 1; // 中心温度計
int sensor = 2; // 置くだけセンサー int sensor = 2; // 置くだけセンサー
int barcode = 3; // バーコード int barcode = 3; // バーコード
int radiationThermomete = 4; // 放射温度計
int sppBluetoothMachine = 5; // SPP通信機器
int nfc = 6; // nfc機器
} }
} }
...@@ -185,10 +185,10 @@ public class JsonUtil { ...@@ -185,10 +185,10 @@ public class JsonUtil {
else if (retType.equals(String.class)) { else if (retType.equals(String.class)) {
return (T) obj.toString(); return (T) obj.toString();
} }
else if ((retType.equals(long.class) || retType.equals(Long.class)) && StringUtil.isNumber(obj.toString())) { else if ((retType.equals(long.class) || retType.equals(Long.class)) && StringUtil.isLongNumber(obj.toString())) {
return (T)(Long)Long.parseLong(obj.toString()); return (T)(Long)Long.parseLong(obj.toString());
} }
else if ((retType.equals(int.class) || retType.equals(Integer.class)) && StringUtil.isNumber(obj.toString())) { else if ((retType.equals(int.class) || retType.equals(Integer.class)) && StringUtil.isLongNumber(obj.toString())) {
return (T)(Integer)Integer.parseInt(obj.toString()); return (T)(Integer)Integer.parseInt(obj.toString());
} }
else if ((retType.equals(double.class) || retType.equals(Double.class)) && StringUtil.isReal(obj.toString())) { else if ((retType.equals(double.class) || retType.equals(Double.class)) && StringUtil.isReal(obj.toString())) {
......
...@@ -35,6 +35,7 @@ import jp.agentec.abook.abv.bl.data.tables.TEnquete; ...@@ -35,6 +35,7 @@ import jp.agentec.abook.abv.bl.data.tables.TEnquete;
import jp.agentec.abook.abv.bl.data.tables.TMarkingSetting; import jp.agentec.abook.abv.bl.data.tables.TMarkingSetting;
import jp.agentec.abook.abv.bl.data.tables.TOperation; import jp.agentec.abook.abv.bl.data.tables.TOperation;
import jp.agentec.abook.abv.bl.data.tables.TPushMessage; import jp.agentec.abook.abv.bl.data.tables.TPushMessage;
import jp.agentec.abook.abv.bl.data.tables.TSppDevice;
import jp.agentec.abook.abv.bl.data.tables.TTask; import jp.agentec.abook.abv.bl.data.tables.TTask;
import jp.agentec.abook.abv.bl.data.tables.TTaskReport; import jp.agentec.abook.abv.bl.data.tables.TTaskReport;
import jp.agentec.abook.abv.bl.data.tables.TTaskReportItems; import jp.agentec.abook.abv.bl.data.tables.TTaskReportItems;
...@@ -95,6 +96,8 @@ public class ABVDataOpenHelper { ...@@ -95,6 +96,8 @@ public class ABVDataOpenHelper {
iTableScripts.add(new TTaskReportItems()); iTableScripts.add(new TTaskReportItems());
iTableScripts.add(new TPushMessage()); iTableScripts.add(new TPushMessage());
// SPP通信端末管理テーブルをスクリプトに追加
iTableScripts.add(new TSppDevice());
return iTableScripts; return iTableScripts;
} }
......
...@@ -3,5 +3,6 @@ package jp.agentec.abook.abv.bl.data; ...@@ -3,5 +3,6 @@ package jp.agentec.abook.abv.bl.data;
// バージョンが上がるごとに+10すること // バージョンが上がるごとに+10すること
public class DatabaseVersions { public class DatabaseVersions {
public static final int Ver1_0_0 = 1; public static final int Ver1_0_0 = 1;
public static final int Ver1_0_2 = 11; // SATO HACCP 1.0.2
} }
package jp.agentec.abook.abv.bl.data.dao;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.dto.SppDeviceDto;
/**
* SPP通信の端末情報を管理する
*/
public class SppDeviceDao extends AbstractDao {
private static final String TAG = "SppDeviceDao";
@Override
protected SppDeviceDto convert(Cursor cursor) {
SppDeviceDto dto = new SppDeviceDto();
int column = cursor.getColumnIndex("spp_device_id");
if (column != -1) {
dto.sppDeviceId = cursor.getInt(column);
}
column = cursor.getColumnIndex("spp_device_name");
if (column != -1) {
dto.sppDeviceName = cursor.getString(column);
}
column = cursor.getColumnIndex("data_start_index");
if (column != -1) {
dto.dataStartIndex = cursor.getInt(column);
}
column = cursor.getColumnIndex("data_end_index");
if (column != -1) {
dto.dataEndIndex = cursor.getInt(column);
}
column = cursor.getColumnIndex("pairing_device_name");
if (column != -1) {
dto.pairingDeviceName = cursor.getString(column);
}
column = cursor.getColumnIndex("pairing_device_address");
if (column != -1) {
dto.pairingDeviceAddress = cursor.getString(column);
}
return dto;
}
/**
* 登録処理
* @param dto
*/
public void insert(SppDeviceDto dto) {
insert("insert into t_spp_device "
+ "(spp_device_id, "
+ "spp_device_name, "
+ "data_start_index, "
+ "data_end_index, "
+ "pairing_device_name, "
+ "pairing_device_address) "
+ "values "
+ "(?,?,?,?,?,?)",
dto.getInsertValues());
}
/**
* SPP通信端末を全て取得
* @return
*/
public List<SppDeviceDto> getAllSppDevice() {
return rawQueryGetDtoList("SELECT * FROM t_spp_device ORDER BY spp_device_id DESC", null, SppDeviceDto.class);
}
/**
* SPP通信端末をIDで検索
* @param sppDeviceId
* @return
*/
public SppDeviceDto getSppDeviceById(Integer sppDeviceId) {
return rawQueryGetDto("SELECT * FROM t_spp_device WHERE spp_device_id = ?", new String[] { "" + sppDeviceId }, SppDeviceDto.class);
}
/**
* SPP通信端末IDを全て取得
* @return
*/
public List<Integer> getSppDeviceIdList() {
return rawQueryGetIntegerList("SELECT spp_device_id FROM t_spp_device ORDER BY spp_device_id DESC", null);
}
/**
* SPP通信端末でペアリング済みデータ取得
* @return
*/
public List<SppDeviceDto> getPairingDeviceList() {
return rawQueryGetDtoList("SELECT * FROM t_spp_device WHERE pairing_device_name is NOT NULL AND pairing_device_address is NOT NULL order by spp_device_id DESC", null, SppDeviceDto.class);
}
/**
* SPP通信端末の更新処理
* @param dto
* @return
*/
public boolean updateSppDevice(SppDeviceDto dto) {
long count = update("UPDATE t_spp_device SET spp_device_name=?, data_start_index=?, data_end_index=?, pairing_device_name=?, pairing_device_address=? WHERE spp_device_id=?", dto.getUpdateValues());
return count > 0;
}
/**
* ペアリングの端末アドレスがユニーク前提
* ペアリング情報をアドレスで取得
* @param deviceAddress
* @return
*/
public SppDeviceDto getPairingDeviceByAddress(String deviceAddress) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT DISTINCT * ");
sql.append(" FROM t_spp_device");
sql.append(" WHERE pairing_device_address = ?");
return rawQueryGetDto(sql.toString(), new String[] { deviceAddress }, SppDeviceDto.class);
}
/**
* ペアリング情報をクリアする
* @param deviceAddress
*/
public void clearPairingDevice(String deviceAddress) {
SppDeviceDto sppDeviceDto = getPairingDeviceByAddress(deviceAddress);
// ペアリング情報を空にして更新
sppDeviceDto.pairingDeviceName = null;
sppDeviceDto.pairingDeviceAddress = null;
updateSppDevice(sppDeviceDto);
}
/**
* SPP端末IDでDB情報を削除
* @param sppDeviceId
*/
public void deleteById(Integer sppDeviceId) {
delete("t_spp_device", "spp_device_id=?", new String[] { "" + sppDeviceId });
}
}
package jp.agentec.abook.abv.bl.data.tables;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
import jp.agentec.abook.abv.bl.data.DatabaseVersions;
/**
* CMS側から取得したSPP通信端末を管理するテーブル
*/
public class TSppDevice extends SQLiteTableScript {
public TSppDevice() {
super();
}
@Override
public List<String> getCreateScript(int version) {
List<String> ddl = new ArrayList<String>();
StringBuffer sql = new StringBuffer();
sql.append(" CREATE TABLE t_spp_device ( ");
sql.append(" spp_device_id INTEGER NOT NULL");
sql.append(" , spp_device_name VARCHAR(256) NOT NULL");
sql.append(" , data_start_index INTEGER NOT NULL ");
sql.append(" , data_end_index INTEGER NOT NULL ");
sql.append(" , pairing_device_name VARCHAR(256) ");
sql.append(" , pairing_device_address VARCHAR(256) ");
sql.append(" , PRIMARY KEY (spp_device_id) ");
sql.append(" ) ");
ddl.add(sql.toString());
return ddl;
}
/**
* マイグレーション処理
* @param oldVersion
* @param newVersion
* @return
*/
@Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>();
if (oldVersion < DatabaseVersions.Ver1_0_2) {
ddl.addAll(getCreateScript(newVersion));
}
return ddl;
}
@Override
public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object[] params) {
return null;
}
}
...@@ -19,8 +19,10 @@ import jp.agentec.abook.abv.bl.data.ABVDataCache; ...@@ -19,8 +19,10 @@ import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao; import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.AcmsDao; import jp.agentec.abook.abv.bl.data.dao.AcmsDao;
import jp.agentec.abook.abv.bl.data.dao.ContentDao; import jp.agentec.abook.abv.bl.data.dao.ContentDao;
import jp.agentec.abook.abv.bl.data.dao.SppDeviceDao;
import jp.agentec.abook.abv.bl.dto.ContentDto; import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.EnqueteDto; import jp.agentec.abook.abv.bl.dto.EnqueteDto;
import jp.agentec.abook.abv.bl.dto.SppDeviceDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic; import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.CategoryLogic; import jp.agentec.abook.abv.bl.logic.CategoryLogic;
import jp.agentec.abook.abv.bl.logic.ContentLogic; import jp.agentec.abook.abv.bl.logic.ContentLogic;
...@@ -51,6 +53,8 @@ import jp.agentec.adf.util.DateTimeUtil; ...@@ -51,6 +53,8 @@ import jp.agentec.adf.util.DateTimeUtil;
private OperationLogic operationLogic = AbstractLogic.getLogic(OperationLogic.class); private OperationLogic operationLogic = AbstractLogic.getLogic(OperationLogic.class);
private ContentDao contentDao = AbstractDao.getDao(ContentDao.class); private ContentDao contentDao = AbstractDao.getDao(ContentDao.class);
private SppDeviceDao sppDeviceDao = AbstractDao.getDao(SppDeviceDao.class);
private ABVDataCache cache = ABVDataCache.getInstance(); private ABVDataCache cache = ABVDataCache.getInstance();
private ContentDownloader contentDownloader = ContentDownloader.getInstance(); private ContentDownloader contentDownloader = ContentDownloader.getInstance();
private NetworkAdapter networkAdapter = ABVEnvironment.getInstance().networkAdapter; private NetworkAdapter networkAdapter = ABVEnvironment.getInstance().networkAdapter;
...@@ -287,6 +291,35 @@ import jp.agentec.adf.util.DateTimeUtil; ...@@ -287,6 +291,35 @@ import jp.agentec.adf.util.DateTimeUtil;
String fetchDate = json.fetchDate; String fetchDate = json.fetchDate;
ABVEnvironment.getInstance().tempContentVersionLastFetchDate = fetchDate; ABVEnvironment.getInstance().tempContentVersionLastFetchDate = fetchDate;
// sppDeviceDtoを登録
List<SppDeviceDto> sppDeviceDtoList = json.sppDeviceDtoList;
if (CollectionUtil.isNotEmpty(sppDeviceDtoList)) {
// ローカルに保存されてるIDリストを取得(登録・更新の判定のため)
List<Integer> localSppDeviceIdList = sppDeviceDao.getSppDeviceIdList();
for (SppDeviceDto sppDeviceDto : sppDeviceDtoList) {
if (CollectionUtil.isNotEmpty(localSppDeviceIdList) && localSppDeviceIdList.contains(sppDeviceDto.sppDeviceId)) {
SppDeviceDto localSppDevice = sppDeviceDao.getSppDeviceById(sppDeviceDto.sppDeviceId);
// ペアリング情報だけローカルから取得して、更新する
sppDeviceDto.pairingDeviceName = localSppDevice.pairingDeviceName;
sppDeviceDto.pairingDeviceAddress = localSppDevice.pairingDeviceAddress;
sppDeviceDao.updateSppDevice(sppDeviceDto);
// 削除のため、更新したら該当するIDを削除する
localSppDeviceIdList.remove(localSppDeviceIdList.indexOf(sppDeviceDto.sppDeviceId));
} else {
// 取得したSPP通信端末のデータベースへ登録
sppDeviceDao.insert(sppDeviceDto);
}
}
// ローカル情報削除(サーバーと端末データの差分)
if (CollectionUtil.isNotEmpty(localSppDeviceIdList)) {
for (Integer deleteSppDeviceId : localSppDeviceIdList) {
sppDeviceDao.deleteById(deleteSppDeviceId);
}
}
}
List<ContentDto> serverContents = json.contentVersions; List<ContentDto> serverContents = json.contentVersions;
// DTO Info:contentId, metaVersion, resourceVersion, contentNameKana, readerShareFlg // DTO Info:contentId, metaVersion, resourceVersion, contentNameKana, readerShareFlg
......
package jp.agentec.abook.abv.bl.dto;
/**
* bluetoothペアリング情報を扱うDto
* デバイス名、デバイスアドレス
*/
public class BluetoothPairingDeviceInfoDto {
/** デバイス名 */
public String deviceName;
/** デバイスアドレス*/
public String deviceAddress;
/** デバイスタイプ*/
public Integer deviceType;
}
package jp.agentec.abook.abv.bl.dto;
/**
* SPP通信の端末情報DTO
*/
public class SppDeviceDto extends AbstractDto {
// SPP通信端末ID
public Integer sppDeviceId;
// SPP通信端末名
public String sppDeviceName;
// 取得したいデータの開始時点
public Integer dataStartIndex;
// 取得したいデータの終了時点
public Integer dataEndIndex;
// ペアリング端末名
public String pairingDeviceName;
// ペアリング端末アドレス
public String pairingDeviceAddress;
@Override
public Object[] getInsertValues() {
return new Object[] { sppDeviceId, sppDeviceName, dataStartIndex, dataEndIndex, pairingDeviceName, pairingDeviceAddress };
}
@Override
public Object[] getUpdateValues() {
return new Object[] { sppDeviceName, dataStartIndex, dataEndIndex, pairingDeviceName, pairingDeviceAddress, sppDeviceId };
}
@Override
public String[] getKeyValues() {
return new String[] { "" + sppDeviceId };
}
}
...@@ -537,7 +537,7 @@ public class StringUtil { ...@@ -537,7 +537,7 @@ public class StringUtil {
} }
} }
public static boolean isNumber(String s) { public static boolean isLongNumber(String s) {
try { try {
Long.parseLong(s); Long.parseLong(s);
return true; return true;
...@@ -546,6 +546,13 @@ public class StringUtil { ...@@ -546,6 +546,13 @@ public class StringUtil {
} }
} }
public static boolean isNumber(String num) {
String regex = "^\\-?[0-9]*\\.?[0-9]+$";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(num);
return m.find();
}
public static boolean isReal(String s) { public static boolean isReal(String s) {
try { try {
Double.parseDouble(s); Double.parseDouble(s);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.NFC" />
<!-- GCM --> <!-- GCM -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" />
...@@ -34,6 +35,9 @@ ...@@ -34,6 +35,9 @@
<!-- BLE --> <!-- BLE -->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/> <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<!-- NFC -->
<uses-feature android:name="android.hardware.nfc" android:required="true"/>
<permission <permission
android:name="${applicationId}.permission.C2D_MESSAGE" android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" /> android:protectionLevel="signature" />
...@@ -224,9 +228,13 @@ ...@@ -224,9 +228,13 @@
<activity android:name="jp.agentec.abook.abv.ui.viewer.activity.CheckOZDViewActivity" android:configChanges="orientation|screenSize"/> <activity android:name="jp.agentec.abook.abv.ui.viewer.activity.CheckOZDViewActivity" android:configChanges="orientation|screenSize"/>
<!-- ABookCheck1.0.0 Sato --> <!-- ABookCheck1.0.0 Sato -->
<activity android:name="jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity" <activity android:name="jp.agentec.abook.abv.ui.home.activity.BlePairingSettingActivity"
android:theme="@style/AppTheme"/> android:theme="@style/AppTheme"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="jp.agentec.abook.abv.ui.home.activity.BarCodeReaderActivity" <activity android:name="jp.agentec.abook.abv.ui.home.activity.BarCodeReaderActivity"
android:theme="@style/AppTheme" android:configChanges="keyboardHidden|orientation|screenSize"/> android:theme="@style/AppTheme"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="jp.agentec.abook.abv.ui.home.activity.SppBluetoothPairingSettingActivity"
android:theme="@style/AppTheme"/>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -1399,23 +1399,38 @@ ...@@ -1399,23 +1399,38 @@
<!-- ABookCheck Sato 1.0.0 --> <!-- ABookCheck Sato 1.0.0 -->
<string name="set_title_pairing">ペアリング</string> <string name="set_title_pairing">ペアリング</string>
<string name="set_pairing_central_thermometer">中心温度計</string> <string name="center_thermometer">中心温度計</string>
<string name="pairing_search_scan">スキャン</string> <string name="pairing_search_scan">スキャン</string>
<string name="pairing_search_scaning">スキャン中..</string> <string name="pairing_search_scaning">スキャン中..</string>
<string name="pairing_search_stop">中止</string> <string name="pairing_search_stop">中止</string>
<string name="pairing_save_thermometer">登録された温度計</string> <string name="pairing_save_thermometer">登録された温度計</string>
<string name="pairing_other_thermometer">その他温度計</string> <string name="pairing_other_thermometer">その他温度計</string>
<string name="pairing_other_thermometer_searching">その他温度計(検索中..)</string> <string name="ble_connecting">接続中...</string>
<string name="ble_connecting">接続中..</string>
<string name="msg_no_device_info">登録された中心温度計情報がありません。\n設定画面のペアリングの中心温度計から登録できます。</string>
<string name="title_okudake_sensor">おくだけセンサー</string> <string name="title_okudake_sensor">おくだけセンサー</string>
<string name="msg_ble_connect_error">登録した中心温度計と接続することができません。中心温度計の電源を確認した後、再度お試しください。(%s)</string> <string name="msg_ble_connect_success">%1$sと接続になりました。%1$sを操作してください。</string>
<string name="msg_ble_connect_success">中心温度計と接続になりました。中心温度計を操作してください。</string> <string name="msg_scan_bluetooth_no_allow">BlueToothの利用を「許可」しないと、%1$sのスキャンができません。</string>
<string name="msg_scan_bluetooth_no_allow">BlueToothの利用を「許可」しないと、中心温度計のスキャンができません。</string> <string name="msg_connect_bluetooth_no_allow">BlueToothの利用を「許可」しないと、%1$sと接続できません。</string>
<string name="msg_thermometer_connect_bluetooth_no_allow">BlueToothの利用を「許可」しないと、中心温度計と接続できません。</string>
<string name="msg_okudake_connect_bluetooth_no_allow">BlueToothの利用を「許可」しないと、おくだけセンサーと接続できません。</string>
<string name="msg_location_device_no_allow">端末の設定から位置情報をONにしてください。</string> <string name="msg_location_device_no_allow">端末の設定から位置情報をONにしてください。</string>
<string name="bluetooth_is_not_supported">Bluetooth機能が利用できない端末です。</string> <string name="bluetooth_is_not_supported">Bluetooth機能が利用できない端末です。</string>
<string name="barcode">コードリーダー</string> <string name="barcode">コードリーダー</string>
<!-- ABookCheck Sato 1.0.2 -->
<string name="chino_machine">CHINO機器</string>
<string name="spp_machine">SPP通信機器</string>
<string name="radiation_thermometer">放射温度計</string>
<string name="pairing_save_machine">登録された%s</string>
<string name="pairing_other_machine">その他%s</string>
<string name="pairing_other_machine_searching">その他%s(検索中...)</string>
<string name="msg_bluetooth_connect_error">登録した%1$sと接続することができません。%1$sの電源を確認した後、再度お試しください。</string>
<string name="msg_bluetooth_receive_data_error">%1$sのデータ取得に失敗しました。</string>
<string name="msg_pairing_device_no_info">登録された%s情報がありません。\n設定画面のペアリング設定から登録できます。</string>
<string name="msg_not_found_parameter">パラメータが存在しません。</string>
<string name="msg_fraud_parameter">パラメータに数値以外の文字列が含まれています。</string>
<string name="msg_okudake_fraud_parameter">おくだけセンサーのパラメータに数値以外の文字列が含まれています。</string> <string name="msg_okudake_fraud_parameter">おくだけセンサーのパラメータに数値以外の文字列が含まれています。</string>
<string name="nfc_communication">NFC通信</string>
<string name="msg_hold_nfc_device">NFC機器をかざしてください。</string>
<string name="msg_nfc_value_error">NFC通信でエラーが発生しました。(%s)</string>
<string name="msg_no_support_nfc">NFC機能が利用できない端末です。</string>
<string name="msg_no_nfc_setting">端末の設定からNFCを有効にする必要があります。\n端末の設定画面へ遷移しますか?</string>
<string name="select_spp_device_title">機器選択</string>
</resources> </resources>
...@@ -1407,23 +1407,36 @@ ...@@ -1407,23 +1407,36 @@
<!-- ABookCheck Sato 1.0.0 --> <!-- ABookCheck Sato 1.0.0 -->
<string name="set_title_pairing">패어링</string> <string name="set_title_pairing">패어링</string>
<string name="set_pairing_central_thermometer">중심 온도계</string> <string name="center_thermometer">중심 온도계</string>
<string name="pairing_search_scan">스캔</string> <string name="pairing_search_scan">스캔</string>
<string name="pairing_search_scaning">스캔중..</string> <string name="pairing_search_scaning">스캔중..</string>
<string name="pairing_search_stop">중지</string> <string name="pairing_search_stop">중지</string>
<string name="pairing_save_thermometer">등록된 온도계</string> <string name="ble_connecting">접속 시도 중...</string>
<string name="pairing_other_thermometer">그 밖에 온도계</string>
<string name="pairing_other_thermometer_searching">그 밖에 온도계(검색중..)</string>
<string name="ble_connecting">접속 시도 중..</string>
<string name="msg_no_device_info">등록된 중심 온도계 정보가 없습니다.\n 설정 화면의 페어링의 중심 온도계에서 등록 가능합니다.</string>
<string name="title_okudake_sensor">오쿠다케 센서</string> <string name="title_okudake_sensor">오쿠다케 센서</string>
<string name="msg_ble_connect_error">등록한 중심 온도계와 연결 할 수 없습니다. 중심 온도계의 전원을 확인후 다시 시도해 주시기 바랍니다.(%s)</string> <string name="msg_ble_connect_success">%1$s와 연결되었습니다. %1$s를 조작 해 주세요.</string>
<string name="msg_ble_connect_success">중심 온도계와 연결되었습니다. 중심 온도계를 조작 해 주세요.</string> <string name="msg_scan_bluetooth_no_allow">블루투스 사용를 [허용] 하지 않으면, %1$s 스캔이 불가능 합니다. </string>
<string name="msg_scan_bluetooth_no_allow">블루투스 사용를 [허용] 하지 않으면, 중심 온도계 스캔이 불가능 합니다. </string> <string name="msg_connect_bluetooth_no_allow">블루투스 사용를 [허용] 하지 않으면, %1$s와 연결이 불가능 합니다.</string>
<string name="msg_thermometer_connect_bluetooth_no_allow">블루투스 사용를 [허용] 하지 않으면, 중심 온도계와 연결이 불가능 합니다.</string>
<string name="msg_okudake_connect_bluetooth_no_allow">블루투스 사용를 [허용] 하지 않으면, 오쿠다케 센서와 연결이 불가능 합니다.</string>
<string name="msg_location_device_no_allow">단말기의 설정에서 위치정보를 ON으로 설정해 주세요.</string> <string name="msg_location_device_no_allow">단말기의 설정에서 위치정보를 ON으로 설정해 주세요.</string>
<string name="bluetooth_is_not_supported">블루투스는 지원되지 않습니다.</string> <string name="bluetooth_is_not_supported">블루투스는 지원되지 않습니다.</string>
<string name="barcode">코드 리더</string> <string name="barcode">코드 리더</string>
<string name="msg_okudake_fraud_parameter">오쿠다케 센서의 파라미터에 숫자가 아닌 문자열이 포합되어 있습니다.</string>
<!-- ABookCheck Sato 1.0.2 -->
<string name="chino_machine">CHINO機器</string>
<string name="spp_machine">SPP通信機器</string>
<string name="radiation_thermometer">放射温度計</string>
<string name="pairing_save_machine">등록된 %s</string>
<string name="pairing_other_machine">그 밖에 %s</string>
<string name="pairing_other_machine_searching">그 밖에 %s(검색중...)</string>
<string name="msg_bluetooth_connect_error">登録した%1$sと接続することができません。%1$sの電源を確認した後、再度お試しください。</string>
<string name="msg_bluetooth_receive_data_error">%1$sのデータ取得に失敗しました。</string>
<string name="msg_pairing_device_no_info">登録された%s情報がありません。\n設定画面のペアリング設定から登録できます。</string>
<string name="msg_not_found_parameter">파라미터가 존재하지 않습니다.</string>
<string name="msg_fraud_parameter">파라미터에 숫자가 아닌 문자열이 포합되어 있습니다.</string>
<string name="msg_okudake_fraud_parameter">おくだけセンサーのパラメータに数値以外の文字列が含まれています。</string>
<string name="nfc_communication">NFC通信</string>
<string name="msg_hold_nfc_device">NFC機器をかざしてください。</string>
<string name="msg_nfc_value_error">NFC通信でエラーが発生しました。(%s)</string>
<string name="msg_no_support_nfc">NFC機能が利用できない端末です。</string>
<string name="msg_no_nfc_setting">端末の設定からNFCを有効にする必要があります。\n端末の設定画面へ遷移しますか?</string>
<string name="select_spp_device_title">機器選択</string>
</resources> </resources>
\ No newline at end of file
...@@ -1405,24 +1405,37 @@ ...@@ -1405,24 +1405,37 @@
<!-- ABookCheck Sato 1.0.0 --> <!-- ABookCheck Sato 1.0.0 -->
<string name="set_title_pairing">Pairing</string> <string name="set_title_pairing">Pairing</string>
<string name="set_pairing_central_thermometer">Central thermometer</string> <string name="center_thermometer">Central thermometer</string>
<string name="pairing_search_scan">Scan</string> <string name="pairing_search_scan">Scan</string>
<string name="pairing_search_scaning">Scaning..</string> <string name="pairing_search_scaning">Scaning...</string>
<string name="pairing_search_stop">Stop</string> <string name="pairing_search_stop">Stop</string>
<string name="pairing_save_thermometer">Saved thermometer</string> <string name="ble_connecting">Connection...</string>
<string name="pairing_other_thermometer">Other thermometer</string>
<string name="pairing_other_thermometer_searching">Other thermometer(Searching..)</string>
<string name="ble_connecting">Connection..</string>
<string name="msg_no_device_info">There is no registered central thermometer information. \n You can register in the center thermometer of the pairing of setting screen.</string>
<string name="title_okudake_sensor">OKUDAKE SENSOR</string> <string name="title_okudake_sensor">OKUDAKE SENSOR</string>
<string name="msg_ble_connect_error">You can not connect to the registered center thermometer. Check the power supply of the central thermometer and try again.(%s)</string> <string name="msg_ble_connect_success">Connected with %1$s. Please control %1$s.</string>
<string name="msg_ble_connect_success">Connected with the center thermometer. Please control the central thermometer.</string> <string name="msg_scan_bluetooth_no_allow">If Bluetooth is not allow, %1$s scan is disabled.</string>
<string name="msg_scan_bluetooth_no_allow">If Bluetooth is not allow, the center thermometer scan is disabled.</string> <string name="msg_connect_bluetooth_no_allow">If Bluetooth is not allow, %1$s connect is disabled.</string>
<string name="msg_thermometer_connect_bluetooth_no_allow">If Bluetooth is not allow, the center thermometer connect is disabled.</string>
<string name="msg_okudake_connect_bluetooth_no_allow">If Bluetooth is not allow, the center okudake sensor connect is disabled.</string>
<string name="msg_location_device_no_allow">Please set the location information to ON in the device setting.</string> <string name="msg_location_device_no_allow">Please set the location information to ON in the device setting.</string>
<string name="bluetooth_is_not_supported">Bluetooth is not supported.</string> <string name="bluetooth_is_not_supported">Bluetooth is not supported.</string>
<string name="barcode">Code Reader</string> <string name="barcode">Code Reader</string>
<string name="msg_okudake_fraud_parameter">The okudake sensor parameter contains a non-numeric string.</string>
<!-- ABookCheck Sato 1.0.2 -->
<string name="chino_machine">CHINO機器</string>
<string name="spp_machine">SPP通信機器</string>
<string name="radiation_thermometer">放射温度計</string>
<string name="pairing_save_machine">Saved %s</string>
<string name="pairing_other_machine">Other %s</string>
<string name="pairing_other_machine_searching">Other %s(Searching...)</string>
<string name="msg_bluetooth_connect_error">登録した%1$sと接続することができません。%1$sの電源を確認した後、再度お試しください。</string>
<string name="msg_bluetooth_receive_data_error">%1$sのデータ取得に失敗しました。</string>
<string name="msg_pairing_device_no_info">登録された%s情報がありません。\n設定画面のペアリング設定から登録できます。</string>
<string name="msg_not_found_parameter">パラメータが存在しません。</string>
<string name="msg_fraud_parameter">The parameter contains a non-numeric string.</string>
<string name="msg_okudake_fraud_parameter">おくだけセンサーのパラメータに数値以外の文字列が含まれています。</string>
<string name="nfc_communication">NFC通信</string>
<string name="msg_hold_nfc_device">NFC機器をかざしてください。</string>
<string name="msg_nfc_value_error">NFC通信でエラーが発生しました。(%s)</string>
<string name="msg_no_support_nfc">NFC機能が利用できない端末です。</string>
<string name="msg_no_nfc_setting">端末の設定からNFCを有効にする必要があります。\n端末の設定画面へ遷移しますか?</string>
<string name="select_spp_device_title">機器選択</string>
</resources> </resources>
\ No newline at end of file
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="wrap_content"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="10dp" android:paddingRight="10dp"
android:orientation="horizontal" android:orientation="horizontal"
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="50dp"
android:orientation="vertical" android:orientation="vertical"
android:gravity="left|center_vertical" android:gravity="left|center_vertical"
android:layout_weight="1"> android:layout_weight="1">
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<TextView <TextView
android:id="@+id/bl_title" android:id="@+id/bl_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:maxWidth="250dp" android:maxWidth="250dp"
...@@ -29,11 +29,22 @@ ...@@ -29,11 +29,22 @@
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/sub_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="right|center_vertical"
android:ellipsize="end"
android:maxLines="1"
android:text="SubTitle"
android:visibility="visible" />
<Button <Button
android:id="@+id/bl_deleteBtn" android:id="@+id/bl_deleteBtn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="right|center_vertical" android:layout_gravity="right|center_vertical"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:text="@string/delete" /> android:text="@string/delete"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/operation_bg"
android:minWidth="500dp"
android:minHeight="300dp"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/toolbar_layout"
style="@style/OperationSearchToolBar"
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:id="@+id/title"
style="@style/DialogToolBarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/select_spp_device_title"
android:textColor="@color/edt_text"
android:textSize="@dimen/opeartion_title_text_size" />
<Button
android:id="@+id/closeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/ic_operation_close"
android:contentDescription="@string/cont_desc" />
</RelativeLayout>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/item_spp_device_select"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/spp_device_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="20dp"
android:padding="10dp"
android:text="@string/dummy_str"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/text_select" />
<ImageView
android:id="@+id/nextLevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="center"
android:src="@drawable/ic_navigation_next_item"
android:visibility="visible" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray" />
</LinearLayout>
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity"> tools:context="jp.agentec.abook.abv.ui.home.activity.BlePairingSettingActivity">
<!--android:background="@drawable/setting_bg"--> <!--android:background="@drawable/setting_bg"-->
<!--android:layout_height="0dp"--> <!--android:layout_height="0dp"-->
<!--android:background="@drawable/setting_bg"--> <!--android:background="@drawable/setting_bg"-->
......
...@@ -60,8 +60,12 @@ ...@@ -60,8 +60,12 @@
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/set_title_pairing" android:key="set_pairing"> <PreferenceCategory android:title="@string/set_title_pairing" android:key="set_pairing">
<PreferenceScreen <PreferenceScreen
android:key="setPairing" android:key="setChinoPairing"
android:title="@string/set_pairing_central_thermometer" > android:title="@string/chino_machine" >
</PreferenceScreen>
<PreferenceScreen
android:key="setSppPairing"
android:title="@string/spp_machine" >
</PreferenceScreen> </PreferenceScreen>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
\ No newline at end of file
package jp.agentec.abook.abv.cl.util;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import java.io.IOException;
import java.util.UUID;
import jp.agentec.abook.abv.bl.common.log.Logger;
/**
* SPP通信のbluetoothの接続スレッド
*/
public class SppBluetoothConnectThread extends Thread {
protected String TAG = "SppBluetoothConnectThread";
// "00001101-0000-1000-8000-00805f9b34fb" = SPP (シリアルポートプロファイル) の UUID.
public static final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
private BluetoothSocket mSocket;
private bluetoothConnectThreadListener mListener;
private BluetoothDevice mBluetoothDevice;
public interface bluetoothConnectThreadListener {
void onConnect(BluetoothSocket socket); // 接続リスナ
void onFail();
}
public SppBluetoothConnectThread(BluetoothDevice device, bluetoothConnectThreadListener listener) {
mListener = listener;
mBluetoothDevice = device;
try {
mSocket = device.createRfcommSocketToServiceRecord(SPP_UUID);
} catch (IOException e) {
Logger.e(TAG, e);
}
}
@Override
public void run() {
if (mSocket == null) {
Logger.e(TAG, "socket is null");
return;
}
try {
mSocket.connect();
} catch (IOException e) {
Logger.e(TAG, e);
try {
if (mSocket == null) {
return;
}
mSocket.close();
} catch (IOException e1) {
Logger.e(TAG, e);
}
mListener.onFail();
return;
}
mListener.onConnect(mSocket);
Logger.i(TAG, "Bluetooth connecting.");
}
public boolean isConnecting() {
return mSocket.isConnected();
}
/**
* ソケットを初期化する
*/
public void finish() {
if (mSocket == null) {
return;
}
try {
mSocket.close();
} catch (IOException e) {
Logger.e(TAG, e);
}
mSocket = null;
}
public String getConnectedAddress() {
if (mBluetoothDevice == null) {
return null;
}
return mBluetoothDevice.getAddress();
}
}
\ No newline at end of file
package jp.agentec.abook.abv.cl.util;
import android.bluetooth.BluetoothSocket;
import java.io.IOException;
import java.io.InputStream;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.SppDeviceDto;
/**
* 大和機器のbluetooth通信でデータを受け取るスレッド
*/
public class YamatoBluetoothReceiveTask extends Thread {
public static final String TAG = "YamatoBluetoothReceiveTask";
private InputStream mInputStream;
private BluetoothSocket mSocket;
private SppDeviceDto mSppDeviceDto;
private static final int STX = 2;
private static final int ETX = 3;
private BluetoothReceiveTaskListener mListener;
public interface BluetoothReceiveTaskListener {
void onGetData(String result); // 値取得時のリスナ
void onFail(boolean dataFormatErrorFlg); // 失敗リスナ
}
public YamatoBluetoothReceiveTask(BluetoothSocket socket, SppDeviceDto sppDeviceDto, BluetoothReceiveTaskListener listener) {
mSocket = null;
mInputStream = null;
mSppDeviceDto = sppDeviceDto;
mListener = listener;
if (socket == null) {
Logger.e(TAG, "parameter socket is null.");
mListener.onFail(false);
return;
}
try {
mSocket = socket;
mInputStream = socket.getInputStream();
} catch (IOException e) {
Logger.e(TAG, e);
mListener.onFail(false);
return;
}
}
@Override
public void run() {
Logger.i(TAG, "bluetoothReciveTask run");
byte[] buffer = new byte[1024];
int readSize = 0;
while (mInputStream != null) {
Logger.i(TAG, "start read mInputStream.");
if (mSocket == null) {
Logger.e(TAG, "mSocket is null.");
break;
}
try {
readSize = mInputStream.read(buffer);
String str = new String(buffer, 0, readSize);
Logger.i(TAG, "getData : " + str);
if (str.indexOf(new Character((char) STX).toString()) != -1 && str.indexOf(new Character((char) ETX).toString()) != -1) {
String dataStr = str.substring(str.indexOf(new Character((char) STX).toString()) + 1, str.indexOf(new Character((char) ETX).toString()));
Logger.i(TAG, "convert data : " + dataStr);
String result = dataStr.substring(mSppDeviceDto.dataStartIndex - 1, mSppDeviceDto.dataEndIndex - 1).replaceAll(" ", "");
mListener.onGetData(result);
}
Thread.sleep(500);
} catch (IndexOutOfBoundsException e) {
Logger.e(TAG, e);
mListener.onFail(true);
break;
} catch (Exception e) {
Logger.e(TAG, e);
mListener.onFail(false);
break;
}
}
Logger.i(TAG, "exit read task.");
}
/**
* ソケットを初期化処理
*/
public void finish() {
if (mSocket == null) {
return;
}
try {
mSocket.close();
mSocket = null;
} catch (IOException e) {
Logger.e(TAG, e);
}
}
}
\ No newline at end of file
...@@ -2,8 +2,10 @@ package jp.agentec.abook.abv.launcher.android; ...@@ -2,8 +2,10 @@ package jp.agentec.abook.abv.launcher.android;
import java.util.ArrayList; import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.Constant.DeviceType;
import jp.agentec.abook.abv.bl.common.Constant.ReportType; import jp.agentec.abook.abv.bl.common.Constant.ReportType;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.BluetoothPairingDeviceInfoDto;
import jp.agentec.abook.abv.cl.util.PreferenceUtil; import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType; import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.DefPrefKey; import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.DefPrefKey;
...@@ -111,6 +113,10 @@ public class ABVUIDataCache { ...@@ -111,6 +113,10 @@ public class ABVUIDataCache {
} }
} }
/**
* フィルターのタイプIDの値セット
* @param operationReportTypes
*/
public void setOperationReportTypes(ArrayList<Integer> operationReportTypes) { public void setOperationReportTypes(ArrayList<Integer> operationReportTypes) {
this.mReportTypes = operationReportTypes; this.mReportTypes = operationReportTypes;
String val = null; String val = null;
...@@ -126,6 +132,10 @@ public class ABVUIDataCache { ...@@ -126,6 +132,10 @@ public class ABVUIDataCache {
PreferenceUtil.putUserPref(context, UserPrefKey.OPERATION_REPORT_TYPES, val); PreferenceUtil.putUserPref(context, UserPrefKey.OPERATION_REPORT_TYPES, val);
} }
/**
* フィルターID情報リスト取得
* @return フィルター用のタイプIDリスト
*/
public ArrayList<Integer> getOperationReportTypes() { public ArrayList<Integer> getOperationReportTypes() {
String operationReportTypesStr = PreferenceUtil.getUserPref(context, UserPrefKey.OPERATION_REPORT_TYPES, null); String operationReportTypesStr = PreferenceUtil.getUserPref(context, UserPrefKey.OPERATION_REPORT_TYPES, null);
...@@ -147,4 +157,111 @@ public class ABVUIDataCache { ...@@ -147,4 +157,111 @@ public class ABVUIDataCache {
return mReportTypes; return mReportTypes;
} }
/**
* アプリ内で保存されてるbluetoothのペアリング情報の
* BluetoothPairingDeviceInfoDtoで返す。
*
* 情報が存在しない場合はnullで返す。
*
* @param bluetoothDeviceType 取得するbluetoothのデバイスタイプ
* @return BluetoothPairingDeviceInfoDto ペアリング情報
*/
public BluetoothPairingDeviceInfoDto getPairingBluetoothDeviceInfo(int bluetoothDeviceType) {
BluetoothPairingDeviceInfoDto dto = new BluetoothPairingDeviceInfoDto();
String deviceName = null;
String deviceAddress = null;
if (bluetoothDeviceType == DeviceType.centerThermomete) {
// 中心温度計
deviceName = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME, "");
deviceAddress = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS, "");
} else if (bluetoothDeviceType == DeviceType.radiationThermomete) {
// 放射温度計
deviceName = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME, "");
deviceAddress = PreferenceUtil.getUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS, "");
}
// deviceNameとdeviceAddressがセットなので、どっちかの値が存在しないとnullで返す。
if (StringUtil.isNullOrEmpty(deviceName) || StringUtil.isNullOrEmpty(deviceAddress)) {
return null;
}
dto.deviceName = deviceName;
dto.deviceAddress = deviceAddress;
dto.deviceType = bluetoothDeviceType;
return dto;
}
/**
* 引数のデバイスタイプでローカルに保存されてるbluetoothのデバイスアドレス取得
* @param bluetoothDeviceType
* @return
*/
public String getPairingBluetoothDeviceAddress(int bluetoothDeviceType) {
String deviceAddressKey = null;
if (bluetoothDeviceType == DeviceType.centerThermomete) {
deviceAddressKey = UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS;
} else if (bluetoothDeviceType == DeviceType.radiationThermomete) {
deviceAddressKey = UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS;
}
if (deviceAddressKey == null) {
// 引数のデバイスタイプが定義した以外の値が入った場合
return null;
}
return PreferenceUtil.getUserPref(context, deviceAddressKey, "");
}
/**
* 引数であるデバイスタイプリストに対するアプリ内で保存されてる
* bluetoothのペアリング情報リストを返す。
* @param deviceTypeList
* @return List<BluetoothPairingDeviceInfoDto> ペアリング情報リスト
*/
public List<BluetoothPairingDeviceInfoDto> getPairingBluetoothDeviceInfoList(List<Integer> deviceTypeList) {
List<BluetoothPairingDeviceInfoDto> bluetoothPairingDeviceInfoDtoList = new ArrayList<BluetoothPairingDeviceInfoDto>();
for (Integer deviceType : deviceTypeList) {
// 引数のデバイスタイプのリスト全部を1つずつデータ取得
BluetoothPairingDeviceInfoDto dto = getPairingBluetoothDeviceInfo(deviceType);
if (dto != null) {
// dtoがnullではない場合のみリストに追加
bluetoothPairingDeviceInfoDtoList.add(dto);
}
}
return bluetoothPairingDeviceInfoDtoList;
}
/**
* ペアリング情報をローカルに保存する
* deviceType毎に保存するキーが異なる
* @param pairingDeviceInfoDto
*/
public void setPairingBluetoothDeviceInfo(BluetoothPairingDeviceInfoDto pairingDeviceInfoDto) {
if (pairingDeviceInfoDto.deviceType.equals(DeviceType.centerThermomete)) {
// 中心温度計
PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME, pairingDeviceInfoDto.deviceName);
PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS, pairingDeviceInfoDto.deviceAddress);
} else if (pairingDeviceInfoDto.deviceType.equals(DeviceType.radiationThermomete)) {
// 放射温度計
PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME, pairingDeviceInfoDto.deviceName);
PreferenceUtil.putUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS, pairingDeviceInfoDto.deviceAddress);
}
}
/**
* 引数であるデバイスタイプの
* ペアリング情報を削除する
* @param deviceType
*/
public void removePairingBluetoothDeviceInfo(int deviceType) {
if (deviceType == DeviceType.centerThermomete) {
// 中心温度計
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_NAME);
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS);
} else if (deviceType == DeviceType.radiationThermomete) {
// 放射温度計
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_NAME);
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS);
}
}
} }
...@@ -57,8 +57,13 @@ public interface AppDefType { ...@@ -57,8 +57,13 @@ public interface AppDefType {
String RESOURCE_PATTERN_TYPE = "resourcePatternType"; // 文言リソースパターン String RESOURCE_PATTERN_TYPE = "resourcePatternType"; // 文言リソースパターン
String BLUETOOTH_DEVICE_TEMPERATURE_NAME = "bleDeviceTemperatureName"; // 温度計機器の名 // 中心温度計
String BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS = "bleDeviceTemperatureAddress"; // 温度計機器のアドレス String BLE_DEVICE_CENTER_TEMPERATURE_NAME = "bleDeviceCenterTemperatureName"; // 中心温度計機器の名
String BLE_DEVICE_CENTER_TEMPERATURE_ADDRESS = "bleDeviceCenterTemperatureAddress"; // 中心温度計機器のアドレス
// 放射温度計
String BLE_DEVICE_RADIATION_TEMPERATURE_NAME = "bleDeviceRadiationTemperatureName"; // 放射温度計機器の名
String BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS = "bleDeviceRadiationTemperatureAddress"; // 放射温度計機器のアドレス
String MASTER_DATA_FETCH_DATE = "masterDataFetchDate"; // マスタデータのFetchDate String MASTER_DATA_FETCH_DATE = "masterDataFetchDate"; // マスタデータのFetchDate
} }
......
...@@ -15,6 +15,7 @@ import java.io.InputStream; ...@@ -15,6 +15,7 @@ import java.io.InputStream;
import jp.agentec.abook.abv.bl.common.ABVEnvironment; import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.download.ContentFileExtractor; import jp.agentec.abook.abv.bl.download.ContentFileExtractor;
import jp.agentec.abook.abv.launcher.android.ABVApplication;
import jp.agentec.abook.abv.launcher.android.R; import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.adf.util.FileUtil; import jp.agentec.adf.util.FileUtil;
...@@ -61,6 +62,8 @@ public class ABookSettingActivity extends PreferenceActivity { ...@@ -61,6 +62,8 @@ public class ABookSettingActivity extends PreferenceActivity {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
// アプリがpauseかどうかの判定を最上位クラスABVActivityで処理が行っていて、設定画面だけ親クラスを参照してないためセットする
((ABVApplication) getApplication()).getABVUIDataCache().visibleActivityName = getClass().getName();
} }
@Override @Override
...@@ -68,6 +71,7 @@ public class ABookSettingActivity extends PreferenceActivity { ...@@ -68,6 +71,7 @@ public class ABookSettingActivity extends PreferenceActivity {
super.onPause(); super.onPause();
} }
// ホーム画面へ戻る処理
private void backToHome() { private void backToHome() {
Intent intent = new Intent(getApplicationContext(), OperationListActivity.class); Intent intent = new Intent(getApplicationContext(), OperationListActivity.class);
...@@ -76,6 +80,10 @@ public class ABookSettingActivity extends PreferenceActivity { ...@@ -76,6 +80,10 @@ public class ABookSettingActivity extends PreferenceActivity {
finish(); finish();
} }
/**
* スマートフォンか判定
* @return
*/
private boolean isNormalSize() { private boolean isNormalSize() {
return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL; return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL;
} }
......
...@@ -35,7 +35,6 @@ import jp.agentec.abook.abv.bl.acms.type.AcmsApis; ...@@ -35,7 +35,6 @@ import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
import jp.agentec.abook.abv.bl.common.ABVEnvironment; import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.CommonExecutor; import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant; import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache; import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto; import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
...@@ -49,19 +48,14 @@ import jp.agentec.abook.abv.launcher.android.OnAppDownloadReceiver; ...@@ -49,19 +48,14 @@ import jp.agentec.abook.abv.launcher.android.OnAppDownloadReceiver;
import jp.agentec.abook.abv.launcher.android.R; import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType; import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey; import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey;
import jp.agentec.abook.abv.ui.common.appinfo.options.Options;
import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog; import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog;
import jp.agentec.abook.abv.ui.common.helper.ProgressDialogHelper; import jp.agentec.abook.abv.ui.common.helper.ProgressDialogHelper;
import jp.agentec.abook.abv.ui.common.util.ABVToastUtil; import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.common.util.PatternStringUtil;
import jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper; import jp.agentec.abook.abv.ui.home.helper.ABookPermissionHelper;
import jp.agentec.adf.util.DateTimeFormat; import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil; import jp.agentec.adf.util.DateTimeUtil;
import static jp.agentec.abook.abv.cl.util.PreferenceUtil.getUserPref;
import static jp.agentec.abook.abv.cl.util.PreferenceUtil.putUserPref;
public class ABookSettingFragment extends PreferenceFragment { public class ABookSettingFragment extends PreferenceFragment {
private static final String TAG = "ABookSettingActivity"; private static final String TAG = "ABookSettingActivity";
...@@ -90,8 +84,9 @@ public class ABookSettingFragment extends PreferenceFragment { ...@@ -90,8 +84,9 @@ public class ABookSettingFragment extends PreferenceFragment {
protected AlertDialog alertDialog = null; protected AlertDialog alertDialog = null;
private SharedPreferences pref; private SharedPreferences pref;
// 機器連携 // 機器連携(ペアリング)
private static final String SET_PAIRING = "setPairing"; private static final String SET_CHINO_PAIRING = "setChinoPairing"; // CHINO機器
private static final String SET_SPP_PAIRING = "setSppPairing"; // SPP通信機器
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
...@@ -475,16 +470,34 @@ public class ABookSettingFragment extends PreferenceFragment { ...@@ -475,16 +470,34 @@ public class ABookSettingFragment extends PreferenceFragment {
// 機器連携のペアリング設定 // 機器連携のペアリング設定
private void setPairingSetting() { private void setPairingSetting() {
PreferenceGroup devicePairing = (PreferenceGroup) findPreference(SET_PAIRING); // CHINO機器
PreferenceGroup chinoDevicePairing = (PreferenceGroup) findPreference(SET_CHINO_PAIRING);
chinoDevicePairing.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
try {
// ペアリング設定画面(BLE通信)
Intent intent = new Intent();
intent.setClass(getActivity(), BlePairingSettingActivity.class);
startActivity(intent);
} catch (Exception e) {
Logger.e(TAG, e);
}
return true;
}
});
// SPP通信機器
PreferenceGroup sppDevicePairing = (PreferenceGroup) findPreference(SET_SPP_PAIRING);
devicePairing.setOnPreferenceClickListener(new OnPreferenceClickListener() { sppDevicePairing.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
try { try {
// ペアリング設定画面 // ペアリング設定画面(SPP通信)
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClass(getActivity(), PairingSettingActivity.class); intent.setClass(getActivity(), SppBluetoothPairingSettingActivity.class);
intent.putExtra("beforeView", SET_PAIRING);
startActivity(intent); startActivity(intent);
} catch (Exception e) { } catch (Exception e) {
Logger.e(TAG, e); Logger.e(TAG, e);
......
...@@ -9,6 +9,7 @@ import jp.agentec.abook.abv.bl.acms.type.RequirePasswordChangeType; ...@@ -9,6 +9,7 @@ import jp.agentec.abook.abv.bl.acms.type.RequirePasswordChangeType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment; import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.CommonExecutor; import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant; import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.Constant.DeviceType;
import jp.agentec.abook.abv.bl.common.Constant.ExceptionDetailMessage; import jp.agentec.abook.abv.bl.common.Constant.ExceptionDetailMessage;
import jp.agentec.abook.abv.bl.common.exception.ABVException; import jp.agentec.abook.abv.bl.common.exception.ABVException;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode; import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
...@@ -19,6 +20,7 @@ import jp.agentec.abook.abv.bl.data.dao.AbstractDao; ...@@ -19,6 +20,7 @@ import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.AcmsDao; import jp.agentec.abook.abv.bl.data.dao.AcmsDao;
import jp.agentec.abook.abv.bl.data.dao.MemberInfoDao; import jp.agentec.abook.abv.bl.data.dao.MemberInfoDao;
import jp.agentec.abook.abv.bl.download.ContentRefresher; import jp.agentec.abook.abv.bl.download.ContentRefresher;
import jp.agentec.abook.abv.bl.dto.BluetoothPairingDeviceInfoDto;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto; import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.dto.PasswordLockInfoDto; import jp.agentec.abook.abv.bl.dto.PasswordLockInfoDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic; import jp.agentec.abook.abv.bl.logic.AbstractLogic;
...@@ -30,7 +32,6 @@ import jp.agentec.abook.abv.cl.environment.DeviceInfo; ...@@ -30,7 +32,6 @@ import jp.agentec.abook.abv.cl.environment.DeviceInfo;
import jp.agentec.abook.abv.cl.util.PreferenceUtil; import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.launcher.android.R; import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVLoginActivity; import jp.agentec.abook.abv.ui.common.activity.ABVLoginActivity;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey; import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.UserPrefKey;
import jp.agentec.abook.abv.ui.common.constant.ErrorCode; import jp.agentec.abook.abv.ui.common.constant.ErrorCode;
import jp.agentec.abook.abv.ui.common.constant.ErrorMessage; import jp.agentec.abook.abv.ui.common.constant.ErrorMessage;
...@@ -56,6 +57,9 @@ import android.widget.ImageButton; ...@@ -56,6 +57,9 @@ import android.widget.ImageButton;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import java.util.Arrays;
import java.util.List;
/** /**
* @author Minhyuk Seok * @author Minhyuk Seok
* @editor Jang * @editor Jang
...@@ -639,20 +643,17 @@ public class LoginActivity extends ABVLoginActivity { ...@@ -639,20 +643,17 @@ public class LoginActivity extends ABVLoginActivity {
* ユーザ変更時の初期化 * ユーザ変更時の初期化
*/ */
private void changeUserInit() { private void changeUserInit() {
// bluetoothの情報維持のため、PreferenceUtil初期化前にデータ取得(CHINO機器)
//中心温度計の情報維持のため、PreferenceUtil初期化前にデータ取得 List<BluetoothPairingDeviceInfoDto> bluetoothPairingInfoDtoList = getABVUIDataCache().getPairingBluetoothDeviceInfoList(Arrays.asList(DeviceType.centerThermomete, DeviceType.radiationThermomete));
String deviceName = getUserPref(AppDefType.UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_NAME, "");
String deviceAddress = getUserPref(AppDefType.UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS, "");
PreferenceUtil.clear(this); PreferenceUtil.clear(this);
getABVUIDataCache().clear(); getABVUIDataCache().clear();
PreferenceUtil.clearUserPref(this); PreferenceUtil.clearUserPref(this);
memberInfoDao.deleteMemberInfo(); memberInfoDao.deleteMemberInfo();
//PreferenceUtil初期化後、中心温度計の情報保存 //PreferenceUtil初期化後、ペアリングの情報保存(CHINO機器)
if (deviceAddress.length() != 0) { for (BluetoothPairingDeviceInfoDto bluetoothPairingDeviceInfoDto : bluetoothPairingInfoDtoList) {
putUserPref(AppDefType.UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_NAME, deviceName); getABVUIDataCache().setPairingBluetoothDeviceInfo(bluetoothPairingDeviceInfoDto);
putUserPref(AppDefType.UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS, deviceAddress);
} }
contentLogic.deleteContentMarkingData(); contentLogic.deleteContentMarkingData();
......
...@@ -12,17 +12,13 @@ import jp.agentec.abook.abv.ui.home.adapter.common.BaseSectionAdapter; ...@@ -12,17 +12,13 @@ import jp.agentec.abook.abv.ui.home.adapter.common.BaseSectionAdapter;
import jp.agentec.abook.abv.ui.home.adapter.common.IndexPath; import jp.agentec.abook.abv.ui.home.adapter.common.IndexPath;
import jp.agentec.abook.abv.ui.home.adapter.common.SectionHeaderData; import jp.agentec.abook.abv.ui.home.adapter.common.SectionHeaderData;
/**
* Created by kim, changgyun on 2018/11/15.
*/
public class BleListAdapter extends BaseSectionAdapter<SectionHeaderData, BleListRowData> { public class BleListAdapter extends BaseSectionAdapter<SectionHeaderData, BleListRowData> {
private static final String TAG = "BleListAdapter"; private static final String TAG = "BleListAdapter";
protected BleListAdapter.BleListAdapterListener listener; protected BleListAdapter.BleListAdapterListener listener;
public interface BleListAdapterListener { public interface BleListAdapterListener {
// 登録されたデバイス情報削除 // 登録されたデバイス情報削除(bluetooth情報を引数としてセット)
void onDeleteConnectInfo(); void onDeleteConnectInfo(BleListRowData rowData);
} }
public BleListAdapter(Context context, List<SectionHeaderData> sectionList, public BleListAdapter(Context context, List<SectionHeaderData> sectionList,
...@@ -56,26 +52,34 @@ public class BleListAdapter extends BaseSectionAdapter<SectionHeaderData, BleLis ...@@ -56,26 +52,34 @@ public class BleListAdapter extends BaseSectionAdapter<SectionHeaderData, BleLis
if (convertView == null) { if (convertView == null) {
convertView = inflater.inflate(R.layout.ble_section_list_row, null); convertView = inflater.inflate(R.layout.ble_section_list_row, null);
holder = new ListRowViewHolder(); holder = new ListRowViewHolder();
// bluetoothのデバイス名
holder.bl_title = (TextView) convertView.findViewById(R.id.bl_title); holder.bl_title = (TextView) convertView.findViewById(R.id.bl_title);
// 該当通信機器の名(中心温度計・放射温度計)
holder.sub_title = (TextView) convertView.findViewById(R.id.sub_title);
// 削除ボタン
holder.bl_deleteBtn = (Button) convertView.findViewById(R.id.bl_deleteBtn); holder.bl_deleteBtn = (Button) convertView.findViewById(R.id.bl_deleteBtn);
convertView.setTag(holder); convertView.setTag(holder);
} else { } else {
holder = (ListRowViewHolder) convertView.getTag(); holder = (ListRowViewHolder) convertView.getTag();
} }
BleListRowData rowData = rowList.get(indexPath.section).get(indexPath.row); final BleListRowData rowData = rowList.get(indexPath.section).get(indexPath.row);
holder.bl_title.setText(rowData.title); holder.bl_title.setText(rowData.title);
//スキャンされた温度計表示時に削除ボタンと接続ステータス非表示 if (rowData.isSaved) {
if (!rowData.isSaved) { // 既に保存されてる場合、削除ボタン表示・機器名は非表示
holder.bl_deleteBtn.setVisibility(View.INVISIBLE); holder.sub_title.setVisibility(View.GONE);
} else {
holder.bl_deleteBtn.setVisibility(View.VISIBLE); holder.bl_deleteBtn.setVisibility(View.VISIBLE);
holder.bl_deleteBtn.setOnClickListener(new View.OnClickListener() { holder.bl_deleteBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
listener.onDeleteConnectInfo(); listener.onDeleteConnectInfo(rowData);
} }
}); });
} else {
// スキャンされたbluetooth機器表示時に削除ボタンと接続ステータス非表示
holder.bl_deleteBtn.setVisibility(View.GONE);
holder.sub_title.setVisibility(View.VISIBLE);
holder.sub_title.setText(rowData.subTitle);
} }
return convertView; return convertView;
} }
...@@ -87,6 +91,7 @@ public class BleListAdapter extends BaseSectionAdapter<SectionHeaderData, BleLis ...@@ -87,6 +91,7 @@ public class BleListAdapter extends BaseSectionAdapter<SectionHeaderData, BleLis
static class ListRowViewHolder { static class ListRowViewHolder {
TextView bl_title; TextView bl_title;
TextView sub_title;
Button bl_deleteBtn; Button bl_deleteBtn;
} }
......
...@@ -17,9 +17,9 @@ public class BleListRowData extends SectionRowData { ...@@ -17,9 +17,9 @@ public class BleListRowData extends SectionRowData {
} }
/** /**
* 中心温度計 * bluetooth情報
* @param title 温度計 * @param title bluetoothデバイス
* @param deviceAddress デバイスアドレス * @param deviceAddress bluetoothデバイスアドレス
* @param isSaved 登録状態 * @param isSaved 登録状態
*/ */
public BleListRowData(String title, String deviceAddress, boolean isSaved) { public BleListRowData(String title, String deviceAddress, boolean isSaved) {
...@@ -27,4 +27,17 @@ public class BleListRowData extends SectionRowData { ...@@ -27,4 +27,17 @@ public class BleListRowData extends SectionRowData {
this.deviceAddress = deviceAddress; this.deviceAddress = deviceAddress;
this.isSaved = isSaved; this.isSaved = isSaved;
} }
/**
* bluetooth情報
* @param title bluetoothデバイス名
* @param subTitle 通信機器名(中心温度計・放射温度計)
* @param deviceAddress bluetoothデバイスアドレス
* @param isSaved 登録状態
*/
public BleListRowData(String title, String subTitle, String deviceAddress, boolean isSaved) {
super(title, subTitle);
this.deviceAddress = deviceAddress;
this.isSaved = isSaved;
}
} }
package jp.agentec.abook.abv.ui.home.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
import jp.agentec.abook.abv.bl.dto.FixPushMessageDto;
import jp.agentec.abook.abv.bl.dto.SppDeviceDto;
import jp.agentec.abook.abv.launcher.android.R;
/**
* SPP端末選択アダプタ用
*/
public class SelectSppDeviceAdapter extends ArrayAdapter<SppDeviceDto> {
private LayoutInflater mInflater;
private List<SppDeviceDto> mSppDeviceDtoList;
public SelectSppDeviceAdapter(Context context, List<SppDeviceDto> sppDeviceDtoList) {
super(context, 0, sppDeviceDtoList);
mSppDeviceDtoList = sppDeviceDtoList;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.item_spp_device_select, parent, false);
holder = new ViewHolder();
holder.tvSppDeviceName = (TextView) convertView.findViewById(R.id.spp_device_name);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final SppDeviceDto sppDeviceDto = getItem(position);
if (sppDeviceDto != null) {
holder.tvSppDeviceName.setText(sppDeviceDto.sppDeviceName);
}
return convertView;
}
private static class ViewHolder {
TextView tvSppDeviceName;
}
}
...@@ -40,7 +40,6 @@ import jp.agentec.abook.abv.ui.common.constant.ErrorMessage; ...@@ -40,7 +40,6 @@ import jp.agentec.abook.abv.ui.common.constant.ErrorMessage;
import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog; import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.common.util.PatternStringUtil; import jp.agentec.abook.abv.ui.common.util.PatternStringUtil;
import jp.agentec.abook.abv.ui.home.helper.ABookCheckWebViewHelper;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper; import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.home.helper.ContentViewHelper; import jp.agentec.abook.abv.ui.home.helper.ContentViewHelper;
import jp.agentec.adf.util.DateTimeFormat; import jp.agentec.adf.util.DateTimeFormat;
...@@ -148,7 +147,7 @@ public class ParentWebViewActivity extends ABVCheckContentViewActivity { ...@@ -148,7 +147,7 @@ public class ParentWebViewActivity extends ABVCheckContentViewActivity {
} }
progressDialog.setProgress(0); progressDialog.setProgress(0);
//中心温度計接続を切る //中心温度計接続を切る
bleThermometerDisconnect(); bleManagerDisconnect();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment