Commit 4d7278ac by Kim Jinsung

#32918 置くだけセンサー

画面調整
parent dfbe01d8
......@@ -162,17 +162,16 @@ public class ContentRefresher {
// マスタデータの最新更新された時のFetchDateを一時に保存する。
Logger.d(TAG, "before fetchDate : " + ABVEnvironment.getInstance().tempMasterDataFetchDate);
try {
// CMSでメンテナンスされるHACCPマスタデータをアプリから取得できるようにJSONファイルを生成する。
String fetchDate = masterDataLogic.initializeMasterData(ABVEnvironment.getInstance().tempMasterDataFetchDate);
Logger.d(TAG, "after fetchDate : " + fetchDate);
// CMSでメンテナンスされるHACCPマスタデータをアプリから取得できるようにJSONファイルを生成する。
String fetchDate = masterDataLogic.initializeMasterData(ABVEnvironment.getInstance().tempMasterDataFetchDate);
Logger.d(TAG, "after fetchDate : " + fetchDate);
if (fetchDate != null) {
// マスタデータの最新更新された時のFetchDateを一時に保存する。
ABVEnvironment.getInstance().tempMasterDataFetchDate = fetchDate;
} catch (Exception e) {
// ログ表示
Logger.e(TAG, "initializeMasterData error : ", e);
}
if (interrupt) { // この時点で停止要求が来た場合先には進まない。(ServiceOption/Group/Categoryの更新は1セットで行う(トランザクションはそれぞれ別))
Logger.d(TAG, "stop refresh worker before content update.");
setFail();
......
......@@ -28,7 +28,7 @@ public class MasterDataLogic extends AbstractLogic {
* @throws Exception その他、例外です。
* @since 1.0.0
*/
public String initializeMasterData(String lastFetchDate) throws NetworkDisconnectedException, AcmsException, IOException {
public String initializeMasterData(String lastFetchDate) {
// コンテンツバージョン用lastFetchDateの取得
AcmsDao dao = AbstractDao.getDao(AcmsDao.class);
String daoLastFetchDate = dao.selectContentVersionLastFetchDate();
......@@ -38,25 +38,30 @@ public class MasterDataLogic extends AbstractLogic {
lastFetchDate = daoLastFetchDate;
}
FetchDateParameters param = new FetchDateParameters(cache.getMemberInfo().sid, lastFetchDate);
MasterDataJSON masterDataJson = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).masterData(param);
String fetchDate = null;
try {
FetchDateParameters param = new FetchDateParameters(cache.getMemberInfo().sid, lastFetchDate);
MasterDataJSON masterDataJson = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).masterData(param);
// get MAP
Map<String, String> masterDataMap = masterDataJson.masterDataMap;
// get MAP
Map<String, String> masterDataMap = masterDataJson.masterDataMap;
// Map に保存されたデータをJSONに変換する。
for (Map.Entry<String, String> entry : masterDataMap.entrySet()) {
System.out.println(entry.getKey() + ":" + entry.getValue());
try {
createMasterDataJson(entry.getKey(), entry.getValue());
} catch (IOException e) {
Logger.e(TAG, "masterDataJSON error : ", e);
throw e;
// Map に保存されたデータをJSONに変換する。
for (Map.Entry<String, String> entry : masterDataMap.entrySet()) {
System.out.println(entry.getKey() + ":" + entry.getValue());
try {
createMasterDataJson(entry.getKey(), entry.getValue());
} catch (IOException e) {
Logger.e(TAG, "masterDataJSON error : ", e);
throw e;
}
}
fetchDate = masterDataJson.fetchDate;
} catch (Exception e) {
Logger.e(TAG, "masterDataSend error : ", e);
}
// masterData の fetchDateを渡す。
return masterDataJson.fetchDate;
return fetchDate;
}
/**
......
......@@ -10,7 +10,7 @@ android {
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 15
minSdkVersion 18
targetSdkVersion 26
//abvEnvironments
resValue("string", "acms_address", "${acms_address}")
......
......@@ -1391,10 +1391,21 @@
<string name="ReportReply_5">報告(回答)(5)</string>
<!-- ABookCheck Sato 1.0.0 -->
<string name="set_pairing">機器連携</string>
<string name="scan">Scan</string>
<string name="stop">Stop</string>
<string name="thermometer">芯温計</string>
<string name="set_title_pairing">ペアリング</string>
<string name="set_pairing_central_thermometer">中心温度計</string>
<string name="pairing_search_scan">スキャン</string>
<string name="pairing_search_stop">中止</string>
<string name="pairing_save_thermometer">登録された温度計</string>
<string name="pairing_other_thermometer">その他温度計</string>
<string name="pairing_other_thermometer_searching">その他温度計(検索中..)</string>
<string name="ble_connect_fail">接続失敗</string>
<string name="ble_disconnect">未接続</string>
<string name="ble_connecting">接続中..</string>
<string name="ble_connect_success">接続済み</string>
<string name="msg_no_device_info">登録された中心温度計情報がありません。\n設定画面のペアリングの中心温度計から登録できます。</string>alert
<string name="ble_is_not_supported">BLEを支援しません。</string>
<string name="bluetooth_is_not_supported">ブルートゥースを支援しません。</string>
<string name="bluetooth_is_not_working">ブルートゥース機能がオンになっているか確認してください。</string>
......@@ -1404,7 +1415,7 @@
<string name="msg_permission_dialog_bluetooth">ブルートゥース利用権限が必要です。\nアプリ設定画面へ遷移します。</string>
<string name="sensor">センサー</string>
<string name="barcode">バーコード</string>
<string name="msg_device_search">ディバイスを検索中</string>
<string name="msg_device_connecting">ディバイスと接続中</string>
<string name="msg_no_device_info">登録された機器情報がありません。\n設定画面の機器連携から確認してください。</string>
</resources>
......@@ -1398,10 +1398,19 @@
<string name="ReportReply_5">보고(회답)(5)</string>
<!-- ABookCheck Sato 1.0.0 -->
<string name="set_pairing">기기연결</string>
<string name="scan">Scan</string>
<string name="stop">Stop</string>
<string name="thermometer">芯温計</string>
<string name="set_title_pairing">패어링</string>
<string name="set_pairing_central_thermometer">중심 온도계</string>
<string name="pairing_search_scan">스캔</string>
<string name="pairing_search_stop">중지</string>
<string name="pairing_save_thermometer">등록된 온도계</string>
<string name="pairing_other_thermometer">그 밖에 온도계</string>
<string name="pairing_other_thermometer_searching">그 밖에 온도계(검색중..)</string>
<string name="ble_connect_fail">접속 실패</string>
<string name="ble_disconnect">접속 안됨</string>
<string name="ble_connecting">접속 시도 중..</string>
<string name="ble_connect_success">접속 완료</string>
<string name="msg_no_device_info">등록된 중심 온도계 정보가 없습니다.\n 설정 화면의 페어링의 중심 온도계에서 등록 가능합니다.</string>
<string name="ble_is_not_supported">BLE는 지원되지 않습니다.</string>
<string name="bluetooth_is_not_supported">블루투스는 지원되지 않습니다.</string>
<string name="bluetooth_is_not_working">블루투스가 작동하지 않습니다.</string>
......@@ -1411,7 +1420,6 @@
<string name="msg_permission_dialog_bluetooth">블루투스이용권한이 필요합니다.\n설정화면으로 이동합니다.</string>
<string name="sensor">센서</string>
<string name="barcode">바코드</string>
<string name="msg_device_search">기기를 검색중\</string>
<string name="msg_device_connecting">기기와 접속중</string>
<string name="msg_no_device_info">등록된 기기정보가 없습니다.\n설정화면의 기기연결에서 확인해주세요.</string>
</resources>
\ No newline at end of file
......@@ -1397,10 +1397,20 @@
<string name="ReportReply_5">ReportReply(5)</string>
<!-- ABookCheck Sato 1.0.0 -->
<string name="set_pairing">Device Connect</string>
<string name="scan">Scan</string>
<string name="stop">Stop</string>
<string name="thermometer">Thermometer</string>
<string name="set_title_pairing">Pairing</string>
<string name="set_pairing_central_thermometer">Central thermometer</string>
<string name="pairing_search_scan">Scan</string>
<string name="pairing_search_stop">Stop</string>
<string name="pairing_save_thermometer">Saved thermometer</string>
<string name="pairing_other_thermometer">Other thermometer</string>
<string name="pairing_other_thermometer_searching">Other thermometer(Searching..)</string>
<string name="ble_connect_fail">Connect fail</string>
<string name="ble_disconnect">Disconnect</string>
<string name="ble_connecting">Connection..</string>
<string name="ble_connect_success">Connected</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="ble_is_not_supported">BLE is not supported.</string>
<string name="bluetooth_is_not_supported">Bluetooth is not supported.</string>
<string name="bluetooth_is_not_working">Bluetooth is not working.</string>
......@@ -1410,7 +1420,6 @@
<string name="msg_permission_dialog_bluetooth">You need Bluetooth access authority. \nIt changes to the application setting.</string>
<string name="sensor">Sensor</string>
<string name="barcode">Barcode</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>
\ No newline at end of file
......@@ -28,7 +28,7 @@ android {
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 15
minSdkVersion 18
targetSdkVersion 26
multiDexEnabled true
}
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@android:color/darker_gray"
android:gravity="center_vertical"
android:minHeight="30dp"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView
android:id="@+id/titleTxt"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:text="Main Title" />
<TextView
android:id="@+id/subTitleTxt"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/titleTxt"
android:gravity="right"
android:text="SubTitle" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="80dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:orientation="horizontal"
android:descendantFocusability="blocksDescendants">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="left|center_vertical"
android:layout_weight="1">
<TextView
android:id="@+id/bl_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:maxWidth="250dp"
android:padding="3dp"
android:text="Main Titledfsafsafsdfsdfsdfsd"
android:gravity="left|center_vertical"
android:textSize="20sp" />
<TextView
android:id="@+id/bl_subTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:padding="3dp"
android:text="connection.."
android:textColor="@android:color/darker_gray"
android:textSize="17sp" />
</LinearLayout>
<Button
android:id="@+id/bl_deleteBtn"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right|center_vertical"
android:layout_marginTop="2dp"
android:text="@string/delete" />
</LinearLayout>
\ No newline at end of file
......@@ -46,14 +46,15 @@
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" />
<Button
android:id="@+id/btn_reload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:background="@android:color/transparent"
android:text="Scan"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
......@@ -75,8 +76,8 @@
<ListView
android:id="@+id/devicelist"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:layout_weight="1" />
......
......@@ -58,10 +58,10 @@
android:title="@string/operation_manual" >
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/set_pairing" android:key="set_pairing">
<PreferenceCategory android:title="@string/set_title_pairing" android:key="set_pairing">
<PreferenceScreen
android:key="setPairing"
android:title="@string/set_pairing" >
android:title="@string/set_pairing_central_thermometer" >
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
......@@ -154,14 +154,14 @@ public class BleManagerUtil {
if( BluetoothGatt.GATT_SUCCESS != status ) {
return;
}
if( UUID_CHARACTERISTIC_PRIVATE1.equals( characteristic.getUuid() ) ) {
final String strTemperature = byteToString(characteristic.getValue());
runOnUiThread( new Runnable() {
public void run() {
// 芯温計の温度を渡す。
listener.onGetDeviceInfo(strTemperature);
// 端末と接続時に呼ばれるのでコメント処理
// listener.onGetDeviceInfo(strTemperature);
}
});
......@@ -250,7 +250,8 @@ public class BleManagerUtil {
// ①「ユーザーの意思による切断」は、mBluetoothGattオブジェクトを解放する。再接続は、オブジェクト構築から。
// ②「接続可能範囲から外れた切断」は、内部処理でmBluetoothGatt.disconnect()処理が実施される。
// 切断時のコールバックでmBluetoothGatt.connect()を呼んでおくと、接続可能範囲に入ったら自動接続する。
mBluetoothGatt.close();
// mBluetoothGatt.close();
mBluetoothGatt.disconnect();
mBluetoothGatt = null;
runOnUiThread( new Runnable() {
......
......@@ -225,14 +225,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
bleManagerUtil = new BleManagerUtil(this, new BleManagerUtil.BleManagerUtilListener() {
@Override
public void onConnectionError() {
Logger.d(TAG, "onDisConnectionState");
Logger.d(TAG, "onConnectionError");
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)));
ABookAlertDialog alert = AlertDialogUtil.createAlertDialog(ABVContentViewActivity.this, R.string.set_pairing_central_thermometer);
alert.setMessage(String.format(getString(R.string.msg_ble_connect_error), getString(R.string.set_pairing_central_thermometer), getString(R.string.set_pairing_central_thermometer)));
alert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setThermometerData("");
bleManagerUtil.disconnect();
}
});
alert.show();
......@@ -240,10 +241,10 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public void onConnectionState() { // 接続
Logger.d(TAG, "onDisConnectionState");
Logger.d(TAG, "onConnectionState");
putUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED, 1);
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.set_pairing_central_thermometer)),
Toast.LENGTH_SHORT);
}
......@@ -252,26 +253,29 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
Logger.d(TAG, "onDisConnectionState");
putUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED, 0);
ABVToastUtil.showMakeText(getApplicationContext(), getString(R.string.msg_ble_not_connect), Toast.LENGTH_SHORT);
setThermometerData("");
}
@Override
public void onGetDeviceInfo(String strTemp) { // 機器のデータ
Logger.d(TAG, "onDisConnectionState");
Logger.d(TAG, "onGetDeviceInfo");
Toast.makeText( getApplicationContext(), strTemp, Toast.LENGTH_SHORT ).show();
Logger.d(TAG, "get temperature [%s]", strTemp);
setThermometerData(strTemp);
bleManagerUtil.disconnect();
}
@Override
public void onGetDeviceInfoFailed() { // 機器のエラー
Logger.d(TAG, "onDisConnectionState");
Logger.d(TAG, "onGetDeviceInfoFailed");
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)));
ABookAlertDialog alert = AlertDialogUtil.createAlertDialog(ABVContentViewActivity.this, R.string.set_pairing_central_thermometer);
alert.setMessage(String.format(getString(R.string.msg_ble_connect_error), getString(R.string.set_pairing_central_thermometer), getString(R.string.set_pairing_central_thermometer)));
alert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setThermometerData("");
bleManagerUtil.disconnect();
}
});
alert.show();
......@@ -1080,6 +1084,9 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
if(isOperationPdf) {
onActionOperationPdfWebView(abookCheckParam, operationTaskDto);
}
if (Constant.XWalkWebViewDisplayStatus.TaskView != mStatusCode) {
bleManagerUtil.disconnect();
}
} else if (mCmd.equals(ABookKeys.CMD_SAVE_ATTACHED)) {
mAttachedFileName = abookCheckParam.get(ABookKeys.FILE_NAME);
getAttachedDataUrl();
......@@ -1434,24 +1441,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
protected void setThermometerDeviceInfo(final boolean showPermissionDialogFlg) {
ABookPermissionHelper helper = new ABookPermissionHelper(this, Constant.ABookPermissionType.Bluetooth, null);
if (helper.checkMultiPermissions(showPermissionDialogFlg)) {
if (getUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS, "").length() > 0) {
String strDeviceName = getUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_NAME, "");
// ローカルに保存されている場合保存されているディバイス情報を読み込んで処理する。
bleManagerUtil.mDeviceAddress = getUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS, "");
int deviceUsed = getUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED, 0);
// 取得したデバイスリストアクティビティからの情報をローカルに保存
setUserPref(strDeviceName, bleManagerUtil.mDeviceAddress, deviceUsed);
String deviceAddress = getUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS, "");
if (deviceAddress.length() > 0) {
// Android端末のBluetooth機能の有効化要求
requestBluetoothFeature();
bleManagerUtil.mDeviceAddress = deviceAddress;
// 接続
bleManagerUtil.connect();
} else {
// 設定画面に遷移すること
// setPairingSetting(); // 接続するのために機器設定画面に遷移する。
// ディバイス情報がない場合
ABookAlertDialog alert = AlertDialogUtil.createAlertDialog(ABVContentViewActivity.this, R.string.thermometer);
ABookAlertDialog alert = AlertDialogUtil.createAlertDialog(ABVContentViewActivity.this, R.string.set_pairing_central_thermometer);
alert.setMessage(getString(R.string.msg_no_device_info));
alert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
......@@ -1459,6 +1457,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
setThermometerData("");
}
});
alert.show();
}
} else {
Logger.w(TAG,"onGetDeviceInfoFailed Connect BLE Device false");
......
......@@ -145,4 +145,11 @@ public interface AppDefType {
interface UrlPattern {
String smart360 = "smart360";
}
interface BlueToothConnectStatus {
int CONNECT_FAIL = -1;
int DISCONNECT = 0;
int CONNECTING = 1;
int CONNECT_SUCCESS = 2;
}
}
......@@ -1079,7 +1079,7 @@ public class OperationListActivity extends ABVUIActivity {
* 360コンテンツ登録ダイアログ
*/
public void showPanoEntryDialog(final OperationDto operationDto) {
Logger.d(TAG, "*****************showPanoEntryDialog");
Logger.d(TAG, "showPanoEntryDialog");
if (contentRefresher != null && contentRefresher.isRefreshing()) {
// 新着更新処理が行っていれば、止める
contentRefresher.stopRefresh();
......
......@@ -4,7 +4,7 @@ import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
......@@ -12,6 +12,9 @@ import java.util.List;
import java.util.Map;
import jp.agentec.abook.abv.launcher.android.R;
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.SectionHeaderData;
import static jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity.DEVICE_CONNECTED;
import static jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity.EXTRAS_DEVICE_ADDRESS;
......@@ -22,7 +25,7 @@ import static org.chromium.base.ThreadUtils.runOnUiThread;
* Created by kim, changgyun on 2018/11/15.
*/
public class BleListAdapter extends BaseAdapter {
public class BleListAdapter extends BaseSectionAdapter<SectionHeaderData, BleListRowData> {
private static final String TAG = "BleListAdapter";
protected BleListAdapter.BleListAdapterListener listener;
private Context mContext;
......@@ -34,142 +37,82 @@ public class BleListAdapter extends BaseAdapter {
private boolean savedDeviceConnected = false; // 保存されているディバスの接続可否
public interface BleListAdapterListener {
// 接続
void onConnect(int postion);
// 切断
void onDisconnect(int position);
// 登録されたデバイス情報削除
void onDeleteConnectInfo();
}
public BleListAdapter(Context context, List<Map<String, String>> listItem, BleListAdapterListener listener) {
mContext = context;
mListItem = listItem;
if (mListItem.size() > 0) {
savedDeviceAddress = mListItem.get(0).get(EXTRAS_DEVICE_ADDRESS);
savedDeviceName = mListItem.get(0).get(EXTRAS_DEVICE_NAME);
savedDeviceConnected = mListItem.get(0).get(DEVICE_CONNECTED) == "1" ? true : false;
}
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
public BleListAdapter(Context context, List<SectionHeaderData> sectionList,
List<List<BleListRowData>> rowList, BleListAdapterListener listener) {
super(context, sectionList, rowList);
this.listener = listener;
}
public List<Map<String, String>> getData() {
return mListItem;
}
// リストへの追加
public void addDevice( Map<String, String> deviceList ) {
if (!mListItem.contains(deviceList)) { // 加えられていなければ加える
mListItem.add(deviceList);
notifyDataSetChanged(); // ListViewの更新
}
}
public void updateDevice(int position, Map<String, String> deviceList) {
if (mListItem.get(position).get(EXTRAS_DEVICE_NAME).equals(deviceList.get(EXTRAS_DEVICE_NAME))) {
// if (mListItem.contains(deviceList)) { // 加えられていなければ加える
mListItem.set(position, deviceList);
savedDeviceAddress = deviceList.get(EXTRAS_DEVICE_ADDRESS);
savedDeviceName = deviceList.get(EXTRAS_DEVICE_NAME);
savedDeviceConnected = deviceList.get(DEVICE_CONNECTED) == "1" ? true : false;
notifyDataSetChanged();
}
}
@Override
public int getCount() {
return mListItem.size();
}
@Override
public Map<String, String> getItem(int position) {
return mListItem.get(position);
}
@Override
public long getItemId( int position ) {
return position;
}
public void setItem(List<Map<String, String>> listItem) {
mListItem= listItem;
}
// リストのクリア
public void clear() {
mListItem.clear();
notifyDataSetChanged(); // ListViewの更新
public View viewForHeaderInSection(View convertView, int section) {
ListHeaderViewHolder holder = null;
if (convertView == null) {
convertView = inflater.inflate(R.layout.ble_section_list_header, null);
holder = new ListHeaderViewHolder();
holder.titleTxt = (TextView) convertView.findViewById(R.id.titleTxt);
holder.subtitleTxt = (TextView) convertView.findViewById(R.id.subTitleTxt);
convertView.setTag(holder);
} else {
holder = (ListHeaderViewHolder) convertView.getTag();
}
SectionHeaderData headerData = sectionList.get(section);
holder.titleTxt.setText(headerData.title);
holder.subtitleTxt.setText(headerData.subTitle);
return convertView;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
public View cellForRowAtIndexPath(View convertView, IndexPath indexPath) {
ListRowViewHolder holder = null;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.pairing_device_list_item, parent, false);
holder = new ViewHolder();
holder.deviceName = (TextView) convertView.findViewById(R.id.textview_devicename);
holder.deviceAddress = (TextView) convertView.findViewById(R.id.textview_deviceaddress);
holder.isConnect = (ImageView) convertView.findViewById(R.id.btn_connect);
holder.isDisConnect = (ImageView) convertView.findViewById(R.id.btn_disconnect);
convertView = inflater.inflate(R.layout.ble_section_list_row, null);
holder = new ListRowViewHolder();
holder.bl_title = (TextView) convertView.findViewById(R.id.bl_title);
holder.bl_subTitle = (TextView) convertView.findViewById(R.id.bl_subTitle);
holder.bl_deleteBtn = (Button) convertView.findViewById(R.id.bl_deleteBtn);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final Map<String, String> device = mListItem.get(position);
String deviceName = device.get(EXTRAS_DEVICE_NAME);
String deviceAddress = device.get(EXTRAS_DEVICE_ADDRESS);
// Logger.d(TAG, "deviceName : [" + deviceName);
// Logger.d(TAG, "deviceAddress : [" + deviceAddress);
// Logger.d(TAG, "defaultDeviceAddress : [" + savedDeviceAddress);
// Logger.d(TAG, "defaultDeviceName : [" + savedDeviceName);
if( null != deviceName && 0 < deviceName.length() && !deviceName.equals(savedDeviceName)) {
holder.deviceName.setText( deviceName );
holder.deviceAddress.setText( deviceAddress );
} else if (null != deviceName && deviceName.equals(savedDeviceName)) {
holder.deviceName.setText( savedDeviceName );
holder.deviceAddress.setText( savedDeviceAddress );
holder = (ListRowViewHolder) convertView.getTag();
}
if (holder.deviceAddress.getText().equals(savedDeviceAddress)) {
if (savedDeviceConnected) {
holder.isConnect.setVisibility(convertView.GONE);
holder.isDisConnect.setVisibility(convertView.VISIBLE);
} else {
holder.isConnect.setVisibility(convertView.VISIBLE);
holder.isDisConnect.setVisibility(convertView.GONE);
}
BleListRowData rowData = rowList.get(indexPath.section).get(indexPath.row);
holder.bl_title.setText(rowData.title);
holder.bl_subTitle.setText(rowData.subTitle);
//スキャンされた温度計表示時に削除ボタンと接続ステータス非表示
if (!rowData.isSaved) {
holder.bl_deleteBtn.setVisibility(View.INVISIBLE);
holder.bl_subTitle.setVisibility(View.GONE);
} else {
holder.isConnect.setVisibility(convertView.VISIBLE);
holder.isDisConnect.setVisibility(convertView.GONE);
holder.bl_deleteBtn.setVisibility(View.VISIBLE);
holder.bl_deleteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onDeleteConnectInfo();
}
});
holder.bl_subTitle.setVisibility(View.VISIBLE);
}
holder.isConnect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onConnect(position);
}
});
holder.isDisConnect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onDisconnect(position);
}
});
return convertView;
}
private static class ViewHolder {
TextView deviceName; // ディバイスの名
TextView deviceAddress; // ディバイスのアドレス
static class ListHeaderViewHolder {
TextView titleTxt;
TextView subtitleTxt;
}
ImageView isConnect; // ディバイスとの接続ボタン
ImageView isDisConnect; // ディバイスとの切断ボタン
static class ListRowViewHolder {
TextView bl_title;
TextView bl_subTitle;
Button bl_deleteBtn;
}
public void setAdapterListener(BleListAdapterListener listener) {
this.listener = listener;
public void setItem(List<SectionHeaderData> sectionList, List<List<BleListRowData>> rowList) {
settingSectionRowData(sectionList, rowList);
notifyDataSetChanged();
}
}
package jp.agentec.abook.abv.ui.home.adapter;
import jp.agentec.abook.abv.ui.home.adapter.common.SectionRowData;
public class BleListRowData extends SectionRowData {
public boolean isSaved;
public String deviceAddress;
/**
* 中心温度計(登録された温度計)
* @param title 温度計名
* @param deviceAddress デバイスアドレス
*/
public BleListRowData(String title, String deviceAddress) {
super(title, null);
this.deviceAddress = deviceAddress;
this.isSaved = false;
}
/**
* 中心温度計(スキャンされた温度計)
* @param title 温度計名
* @param subTitle 接続状態
* @param deviceAddress デバイスアドレス
*/
public BleListRowData(String title, String subTitle, String deviceAddress) {
super(title, subTitle);
this.deviceAddress = deviceAddress;
this.isSaved = true;
}
}
package jp.agentec.abook.abv.ui.home.adapter.common;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class BaseSectionAdapter<T1, T2> extends BaseAdapter {
/** インデックス行:ヘッダー */
private static final int INDEX_PATH_ROW_HEADER = -1;
/** ビュータイプ:ヘッダー行 */
private static final int ITEM_VIEW_TYPE_HEADER = 0;
/** ビュータイプ:データ行 */
private static final int ITEM_VIEW_TYPE_ROW = 1;
protected Context context;
protected LayoutInflater inflater;
/** ヘッダー行で使用するデータリスト */
protected List<T1> sectionList;
/** データ行で使用するデータリスト */
protected List<List<T2>> rowList;
private List<IndexPath> indexPathList;
public BaseSectionAdapter(Context context, List<T1> sectionList, List<List<T2>> rowList) {
super();
this.context = context;
this.inflater = LayoutInflater.from(context);
this.sectionList = sectionList;
this.rowList = rowList;
this.indexPathList = getIndexPathList(sectionList, rowList);
}
@Override
public int getCount() {
int count = indexPathList.size();
return count;
}
@Override
public Object getItem(int position) {
IndexPath indexPath = indexPathList.get(position);
if (isHeader(indexPath)) {
return sectionList.get(indexPath.section);
} else {
return rowList.get(indexPath.section).get(indexPath.row);
}
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
IndexPath indexPath = indexPathList.get(position);
// ヘッダー行とデータ行とで分岐します。
if (isHeader(indexPath)) {
return viewForHeaderInSection(convertView, indexPath.section);
} else {
return cellForRowAtIndexPath(convertView, indexPath);
}
}
/**
* ヘッダー行のViewを返します。
*
* @param convertView
* @param section
* @return ヘッダー行のView
*/
public View viewForHeaderInSection(View convertView, int section) {
if (convertView == null) {
convertView = inflater.inflate(android.R.layout.simple_list_item_1, null);
TextView castedConvertView = (TextView) convertView;
castedConvertView.setBackgroundColor(Color.GRAY);
castedConvertView.setTextColor(Color.WHITE);
}
TextView textView = (TextView) convertView;
textView.setText(sectionList.get(section).toString());
return convertView;
}
/**
* データ行のViewを返します。
*
* @param convertView
* @param indexPath
* @return データ行のView
*/
public View cellForRowAtIndexPath(View convertView, IndexPath indexPath) {
if (convertView == null) {
convertView = inflater.inflate(android.R.layout.simple_list_item_1, null);
}
TextView textView = (TextView) convertView;
textView.setText(rowList.get(indexPath.section).get(indexPath.row).toString());
return convertView;
}
@Override
public int getViewTypeCount() {
// ヘッダー行とデータ行の2種類なので、2を返します。
return 2;
}
@Override
public int getItemViewType(int position) {
// ビュータイプを返します。
if (isHeader(position)) {
return ITEM_VIEW_TYPE_HEADER;
} else {
return ITEM_VIEW_TYPE_ROW;
}
}
@Override
public boolean isEnabled(int position) {
if (isHeader(position)) {
// ヘッダー行の場合は、タップできないようにします。
return false;
} else {
IndexPath indexPath = indexPathList.get(position);
SectionRowData rowData = (SectionRowData) rowList.get(indexPath.section).get(indexPath.row);
if (rowData.title.isEmpty()) { //タイトルが空白の場合はタップ不能に設定
return false;
}
return super.isEnabled(position);
}
}
/**
* インデックスパスリストを取得します。
*
* @param sectionList
* @param rowList
* @return インデックスパスリスト
*/
private List<IndexPath> getIndexPathList(List<T1> sectionList, List<List<T2>> rowList) {
List<IndexPath> indexPathList = new ArrayList<IndexPath>();
for (int i = 0; i < sectionList.size(); i++) {
IndexPath sectionIndexPath = new IndexPath();
sectionIndexPath.section = i;
sectionIndexPath.row = INDEX_PATH_ROW_HEADER;
indexPathList.add(sectionIndexPath);
List<T2> rowListBySection = rowList.get(i);
for (int j = 0; j < rowListBySection.size(); j++) {
IndexPath rowIndexPath = new IndexPath();
rowIndexPath.section = i;
rowIndexPath.row = j;
indexPathList.add(rowIndexPath);
}
}
return indexPathList;
}
private boolean isHeader(int position) {
IndexPath indexPath = indexPathList.get(position);
return isHeader(indexPath);
}
private boolean isHeader(IndexPath indexPath) {
if (INDEX_PATH_ROW_HEADER == indexPath.row) {
return true;
} else {
return false;
}
}
protected void settingSectionRowData(List<T1> sectionList, List<List<T2>> rowList) {
this.sectionList = sectionList;
this.rowList = rowList;
this.indexPathList = getIndexPathList(sectionList, rowList);
}
}
package jp.agentec.abook.abv.ui.home.adapter.common;
public class IndexPath {
public int section;
public int row;
}
package jp.agentec.abook.abv.ui.home.adapter.common;
/**
* ListViewのAdapterで利用するSectionの値設定クラス
*/
public class SectionHeaderData {
/**
* 中心温度計用
* @param title タイトル
*/
public SectionHeaderData(String title) {
this.title = title;
}
/**
* 共通用
* @param title タイトル
* @param subTitle サブタイトル
*/
public SectionHeaderData(String title, String subTitle) {
this.title = title;
this.subTitle = subTitle;
}
public String title;
public String subTitle;
}
\ No newline at end of file
package jp.agentec.abook.abv.ui.home.adapter.common;
/**
* ListViewのAdapterで利用するRowの値設定クラス
*/
public class SectionRowData {
/**
* 共通用
* @param title タイトル
* @param subTitle サブタイトル
*/
public SectionRowData(String title, String subTitle) {
this.title = title;
this.subTitle = subTitle;
}
public String title;
public String subTitle;
}
......@@ -222,7 +222,7 @@ public class HTMLXWalkWebViewActivity extends ParentWebViewActivity {
public void openFileChooser(XWalkView view, ValueCallback<Uri> uploadFile,
String acceptType, String capture) {
super.openFileChooser(view, uploadFile, acceptType, capture);
Logger.d(TAG, "*********************commonOpenFileChooser");
Logger.d(TAG, "commonOpenFileChooser");
boolean result = false;
if (acceptType.toLowerCase().indexOf(ABookKeys.IMAGE) != -1) {
result = startCameraIntent(ABOOK_CHECK_TASK_IMAGE, "Camera", ABookKeys.IMAGE, true);
......
......@@ -38,12 +38,12 @@ app_versioncode=1
# abvEnvironments.xml
#cms server
acms_address=https://abook189.abook.bz/acms
download_server_address=https://abook189.abook.bz/acms
acms_address=https://check.abookcloud.com/acms
download_server_address=https://check.abookcloud.com/acms
#syncview server
websocket_server_http_url=https://abookplus.agentec.jp/v1
websocket_server_ws_url=wss://abookplus.agentec.jp/v1
websocket_server_http_url=https://abook188-1.abook.bz/v1
websocket_server_ws_url=wss://abook188-1.abook.bz/v1
#WebSocket debug出力
websocket_debug=false
......@@ -93,7 +93,7 @@ hope_page=http://www.agentec.jp
contact_email=abook-appsupport@agentec.jp
#Log Settings
log_level=2
log_level=0
default_log_name=abvje
#エラーレポート/Exportログ送信方法 1:acms 2:平文メール(開発・テスト時のみ) 3:暗号化添付メール
error_report_flg=1
......
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