Commit a01ca2f5 by Jeong Gilmo

#32960 ペアリング設定画面

- 設定画面から機器連携項目追加
- 機器連携画面で芯温計と接続処理追加
- BLE の機器と検索、接続、切断処理機能の追加
parent 49ba3b58
......@@ -30,6 +30,9 @@
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<!-- BLE -->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
......@@ -210,5 +213,8 @@
<activity android:name="jp.agentec.abook.abv.ui.viewer.activity.CheckOZDViewActivity" android:configChanges="orientation|screenSize"/>
<!-- ABookCheck1.0.0 Sato -->
<activity android:name="jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity"
android:theme="@style/AppTheme"/>
</application>
</manifest>
\ No newline at end of file
......@@ -1370,4 +1370,17 @@
<string name="Report_5">報告(5)</string>
<string name="Routine_5">定期点検(5)</string>
<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="ble_is_not_supported">BLEを支援しません。</string>
<string name="bluetooth_is_not_supported">ブルートゥースを支援しません。</string>
<string name="bluetooth_is_not_working">ブルートゥースが機能しません。</string>
<string name="msg_connected_bluetooth">%sに接続されました。</string>
<string name="msg_ble_not_connect">接続が停止しました。</string>
<string name="msg_ble_connect_error">%sと接続されていません。\n%sと接続状態を設定画面の機器連携から確認してください。</string>
</resources>
......@@ -1371,4 +1371,17 @@
<string name="Report_5">보고(5)</string>
<string name="Routine_5">정기점검(5)</string>
<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="ble_is_not_supported">BLE는 지원되지 않습니다.</string>
<string name="bluetooth_is_not_supported">블루투스는 지원되지 않습니다.</string>
<string name="bluetooth_is_not_working">블루투스가 작동하지 않습니다.</string>
<string name="msg_connected_bluetooth">%s에 접속되었습니다</string>
<string name="msg_ble_not_connect">접속이 정지되었습니다.</string>
<string name="msg_ble_connect_error">%s랑 접속되지않습니다.\n%s와의 접속상태를 설정화면의 기기연결에서 확인해주세요.</string>
</resources>
\ No newline at end of file
......@@ -1370,4 +1370,17 @@
<string name="Report_5">Report(5)</string>
<string name="Routine_5">Routine(5)</string>
<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="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>
<string name="msg_connected_bluetooth">Connected to %s</string>
<string name="msg_ble_not_connect">The connection has stopped.</string>
<string name="msg_ble_connect_error">Not connected with% %s. \nCheck %s and connection status from the device linkage on the setting screen.</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/textview_devicename"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="24dp"/>
<TextView
android:id="@+id/textview_deviceaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12dp"/>
</LinearLayout>
<ImageView
android:id="@+id/btn_connect"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="3dp"
android:background="@drawable/ic_reload_list"/>
<ImageView
android:id="@+id/btn_disconnect"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="3dp"
android:background="@drawable/ic_delete"/>
</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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity">
<!--android:background="@drawable/setting_bg"-->
<!--android:layout_height="0dp"-->
<!--android:background="@drawable/setting_bg"-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
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/tv_toolbar_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/set_pairing"
android:textColor="@color/edt_text"
android:textSize="@dimen/opeartion_title_text_size" />
<ImageButton
android:id="@+id/close_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@drawable/ic_operation_close"
android:onClick="onClickCloseView" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:visibility="visible">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:gravity="left"
android:text="@string/thermometer"
android:textSize="20sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true">
<Button
android:id="@+id/scan_button"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:text="@string/scan" />
<Button
android:id="@+id/stop_button"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:text="@string/stop" />
</LinearLayout>
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" />
<ListView
android:id="@+id/devicelist"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="8dp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
......@@ -58,4 +58,10 @@
android:title="@string/operation_manual" >
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/set_pairing" android:key="set_pairing">
<PreferenceScreen
android:key="setPairing"
android:title="@string/set_pairing" >
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
......@@ -56,6 +56,10 @@ public interface AppDefType {
String OPERATION_REPORT_TYPES = "operationReportTypes";
String RESOURCE_PATTERN_TYPE = "resourcePatternType"; // 文言リソースパターン
String BLUETOOTH_DEVICE_TEMPERATURE_NAME = "bleDeviceTemperatureName"; // 温度計機器の名
String BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS = "bleDeviceTemperatureAddress"; // 温度計機器のアドレス
String BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED = "bleDeviceTemperatureConnected"; // 芯温計機器と接続可否
}
/**
......
......@@ -90,6 +90,9 @@ public class ABookSettingFragment extends PreferenceFragment {
protected AlertDialog alertDialog = null;
private SharedPreferences pref;
// 機器連携
private static final String SET_PAIRING = "setPairing";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -104,6 +107,9 @@ public class ABookSettingFragment extends PreferenceFragment {
setLogInfoSetting();
// アプリ情報
setAppInfoSetting();
// ペアリング設定
setPairingSetting();
}
@Override
......@@ -461,4 +467,25 @@ public class ABookSettingFragment extends PreferenceFragment {
Logger.d(TAG, "saveLeaveAppTime()");
PreferenceUtil.putUserPref(getActivity(), UserPrefKey.LEAVE_APP, System.currentTimeMillis());
}
// 機器連携のペアリング設定
private void setPairingSetting() {
PreferenceGroup devicePairing = (PreferenceGroup) findPreference(SET_PAIRING);
devicePairing.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
try {
// ペアリング設定画面
Intent intent = new Intent();
intent.setClass(getActivity(), PairingSettingActivity.class);
intent.putExtra("beforeView", SET_PAIRING);
startActivity(intent);
} catch (Exception e) {
Logger.e(TAG, e);
}
return true;
}
});
}
}
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.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
import java.util.Map;
import jp.agentec.abook.abv.launcher.android.R;
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;
import static jp.agentec.abook.abv.ui.home.activity.PairingSettingActivity.EXTRAS_DEVICE_NAME;
import static org.chromium.base.ThreadUtils.runOnUiThread;
/**
* Created by kim, changgyun on 2018/11/15.
*/
public class BleListAdapter extends BaseAdapter {
private static final String TAG = "BleListAdapter";
protected BleListAdapter.BleListAdapterListener listener;
private Context mContext;
private LayoutInflater mInflater;
private List<Map<String, String>> mListItem;
private String savedDeviceAddress = ""; // 保存されているディバイスのアドレス
private String savedDeviceName = ""; // 保存されているディバイスの名
private boolean savedDeviceConnected = false; // 保存されているディバスの接続可否
public interface BleListAdapterListener {
// 接続
void onConnect(int postion);
// 切断
void onDisconnect(int position);
}
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);
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の更新
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
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.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 );
}
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);
}
} else {
holder.isConnect.setVisibility(convertView.VISIBLE);
holder.isDisConnect.setVisibility(convertView.GONE);
}
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; // ディバイスのアドレス
ImageView isConnect; // ディバイスとの接続ボタン
ImageView isDisConnect; // ディバイスとの切断ボタン
}
public void setAdapterListener(BleListAdapterListener listener) {
this.listener = listener;
}
}
package jp.agentec.abook.abv.ui.home.helper;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
......@@ -82,6 +83,11 @@ public class ABookPermissionHelper {
android.Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.RECORD_AUDIO);
}
// Bluetooth
if (ContextCompat.checkSelfPermission(mActivity,
android.Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.BLUETOOTH);
}
return reqPermissions;
}
......@@ -149,6 +155,17 @@ public class ABookPermissionHelper {
getUserPref(getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
break;
// Confirm Device Bluetooth
case Constant.ABookPermissionType.Bluetooth:
if (ContextCompat.checkSelfPermission(mActivity,
Manifest.permission.BLUETOOTH) != PERMISSION_GRANTED) {
// リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_permission_dialog_bluetooth,
getUserPref(getApplicationContext(), AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
break;
}
if (permitionTextResourceId > 0) {
......
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